Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rakesh_kumar
Creator
Creator

For loop to generate data

Hi Guys,

I am trying to create a table with data as follows:

For 1=1 to 1000000

NewTable:

Load $(i) as Counter

AutoGenerate 1;

NEXT

When the above code is executed its taking nearly 20 minutes to create a table with 1 million rows. Is there any other efficient way of modifying code to reduce the time taken for the creation of the above table?

Thanks,

RK

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

LOAD

     RecNo() AS Counter

AUTOGENERATE

     1000000;

View solution in original post

5 Replies
petter
Partner - Champion III
Partner - Champion III

LOAD

     RecNo() AS Counter

AUTOGENERATE

     1000000;

rakesh_kumar
Creator
Creator
Author

Hi Petter,

Thanks for the code and Its very fast now.

Please can you tell why the looping is so slow compared to your approach?

Thanks,

RK

ToniKautto
Employee
Employee

Petter's example generates ONE load statement that contains one million rows.

In your original example you generate 1 million load statements, which then  are concatenated into one common table.

Your approach simply adds an enormous amount of processing overhead.

Not applicable

Hi Rakesh,

Try like this:

LOAD

     RecNo() AS ID

AUTOGENERATE

     n;

Ramaya.

rakesh_kumar
Creator
Creator
Author

Thanks Toni for the simple and easy to understand explanation