← Back to team overview

dhis2-devs team mailing list archive

Re: Generating 2.5 mill UIDs and saving them to a file

 

Morten,

Firstly, thanks for confirming there's a hard-coded limit - I suspected it,
but found no reference to any limits in the developer manual.

Secondly, I did generate them easily enough using Bob's uid function and a
small temp table to store the uids:
DO
$do$
BEGIN
FOR i IN 1..2411000 LOOP
    INSERT INTO aa_uid SELECT uid() as uidno;
END LOOP;
END
$do$;

BUT your use of COPY and GENERATE_SERIES is neater with no need for a temp
table - thanks for that! Works like a charm...

Regards
Calle

On 26 June 2017 at 03:18, Morten Olav Hansen <morten@xxxxxxxxx> wrote:

> (and no, there is a limit for generating UIDs in the web-api for a
> reason... that endpoint is open to everyone, and you could kill servers if
> we allowed no upper limit)
>
> --
> Morten Olav Hansen
> Senior Engineer, DHIS 2
> University of Oslo
> http://www.dhis2.org
>
> On Mon, Jun 26, 2017 at 8:16 AM, Morten Olav Hansen <morten@xxxxxxxxx>
> wrote:
>
>> Hi Calle
>>
>> Just use something like this (you need to have the uid() function
>> installed first)
>>
>> copy (select uid() as uid from generate_series(1,10)) to '/tmp/test.csv';
>>
>> and replace 10 with whatever number you want
>>
>> --
>> Morten Olav Hansen
>> Senior Engineer, DHIS 2
>> University of Oslo
>> http://www.dhis2.org
>>
>> On Mon, Jun 26, 2017 at 7:25 AM, Jason Pickering <
>> jason.p.pickering@xxxxxxxxx> wrote:
>>
>>> Call the same end point 250 times maybe and concatenate to a file? 😕
>>>
>>> On Jun 25, 2017 18:11, "Calle Hedberg" <calle.hedberg@xxxxxxxxx> wrote:
>>>
>>> Knut
>>>
>>> Aware of that, but it generates only one UID.  I can use it in a small
>>> program, of course, but that's not the point here:
>>>
>>> I would like to know if there is a way to get the web API to create 2.5
>>> mill UIDs into a csv file.
>>>
>>> Regards
>>> Calle
>>>
>>> On 25 June 2017 at 23:45, Knut Staring <knutst@xxxxxxxxx> wrote:
>>>
>>>> By courtesy of Bob:
>>>>
>>>> https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/uid.sql
>>>>
>>>> On Sun, Jun 25, 2017 at 11:33 PM, Calle Hedberg <
>>>> calle.hedberg@xxxxxxxxx> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I need around 2.5 mill UIDs for use as event UIDs, but the following
>>>>> only returns 10,000 (this might be a browser setting - not sure):
>>>>>
>>>>> http://localhost:8080/dhis//api/26/system/id.csv?limit=25000
>>>>> 00&paging=false
>>>>>
>>>>> Any other way to generate those 2.5 mill UIDs and dump them directly
>>>>> out into a csv file?
>>>>>
>>>>> Regards
>>>>> calle
>>>>>
>>>>> *******************************************
>>>>>
>>>>> Calle Hedberg
>>>>>
>>>>> 46D Alma Road, 7700 Rosebank, SOUTH AFRICA
>>>>>
>>>>> Tel/fax (home): +27-21-685-6472 <+27%2021%20685%206472>
>>>>>
>>>>> Cell: +27-82-853-5352 <+27%2082%20853%205352>
>>>>>
>>>>> Iridium SatPhone: +8816-315-19119 <+881%206%20315%2019119>
>>>>>
>>>>> Email: calle.hedberg@xxxxxxxxx
>>>>>
>>>>> Skype: calle_hedberg
>>>>>
>>>>> *******************************************
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Knut Staring
>>>> Dept. of Informatics, University of Oslo
>>>> Norway: +4791880522 <+47%20918%2080%20522>
>>>> Skype: knutstar
>>>> http://dhis2.org
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> *******************************************
>>>
>>> Calle Hedberg
>>>
>>> 46D Alma Road, 7700 Rosebank, SOUTH AFRICA
>>>
>>> Tel/fax (home): +27-21-685-6472 <+27%2021%20685%206472>
>>>
>>> Cell: +27-82-853-5352 <+27%2082%20853%205352>
>>>
>>> Iridium SatPhone: +8816-315-19119 <+881%206%20315%2019119>
>>>
>>> Email: calle.hedberg@xxxxxxxxx
>>>
>>> Skype: calle_hedberg
>>>
>>> *******************************************
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>


-- 

*******************************************

Calle Hedberg

46D Alma Road, 7700 Rosebank, SOUTH AFRICA

Tel/fax (home): +27-21-685-6472

Cell: +27-82-853-5352

Iridium SatPhone: +8816-315-19119

Email: calle.hedberg@xxxxxxxxx

Skype: calle_hedberg

*******************************************

References