Search code examples
azureazure-web-app-serviceazure-cosmosdb

How can i create with fastest method 250.000.000.000 rows data


Helllo all,

I wanted to create on azure cosmosdb items which one has location coordinates. Yesterday i created a method on API below:

  [HttpGet("createzone")]

    public async Task<ActionResult<string>> CreateZones()

    {
        Container container = database.GetContainer(containerId);

        double x = 38.988599999993035;
        double y = 26.003399999999992;
        int id = 524962;
        while (y < 45.0000000001)
        {
            Console.WriteLine("x: " + x + " y: " + y);
            Zone newZone = new Zone
            {
                Id = "Zone." + id.ToString(),
                Title = "Zone" + id.ToString(),
                Owner = null,
                Coordinate = new Coordinate { Latitude = x, Longitude = y },
                PartitionKey = "id." + id.ToString()

            };
            await container.CreateItemAsync<Zone>(newZone, new PartitionKey(newZone.PartitionKey));

            x += 0.0002;
            id += 1;
            if (x>42)
            {
                y += 0.0002;
                x = 36;
            }
        }
        return "done";
    }

according to my calculations it will take more than 3 years for the data to be generated if it continues like this

What i neeed: Creating areas shown with squares on the map in the application and ensuring that all of these areas have a unique number. Like this: enter image description here

I did same visual in my app now. but creating areas taking too much time.

How can i create on fastest way these items?


Solution

  • It does not look like you have implemented this using bulk import pattern with Cosmos DB. There's a lot to gain using that. While doing this, also monitor the used RUs when you execute and consider increasing RUs for the duration of the operation.