Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

Employee
Employee

Limited Load and the First Prefix

Have you ever had an application that takes a long time to reload and you dread making changes to the script because that would require you to wait until the reload is complete to make sure your changes are working correctly?  Well QlikView and Qlik Sense both provide options that allow you to test your script without waiting for the entire reload to complete – Limited Load and the First prefix.

QlikView and Qlik Sense have Debug capabilities that allow you to do a Limited Load.  With each product, you can enter the maximum number of records that each Load and Select statement can load.  This reduces the execution time of the reload but still lets you to test that the script runs properly.  Limited load can be very useful when the data sources are large or when you are testing with live data and want to keep the execution time low.

In QlikView and Qlik Sense, you can access the Debug window from the script editor.  In QlikView, you can find it in the File menu or on the toolbar.

QV toolbar.png

QV menu.png

The Debug window looks like the image below.  You can check the Limited Load checkbox and enter the maximum number of records you want loaded with each Load and Select statement.

QV debug windoe.png

In Qlik Sense, you can also access the Debug panel from the Data Load Editor.

QS toolbar.png

Clicking on the Debug icon opens the Debug panel at the bottom of the page.  You can check the Limited Load checkbox and then enter the maximum number of records you want loaded with each Load and Select statement.

QS debug window.png

Another option that can be used to reduce the number of records loaded is the First prefix.  This can also be used with a Load or Select statement to set the maximum number of records that are loaded.  The difference between the Limited Load and the First prefix is that the Limited Load will apply to all Load and Select statements in the script whereas the First prefix is manually added to each Load or Select statement that it should apply to.  For example, I could run the script below to load only 10 customers from the Customers QVD.

script.png

The First prefix can be written as it is above or with parenthesis like this: First (10) LOAD.  If there are many Load and Select statements in the script, a Limited Load may be easier to use but if there are only a few Load/Select statements or if there is one data source in particular that has a lot of records, then the FIRST prefix may work best.

Keep in mind when using Limited Load or the First prefix that all the data may not be loaded and you may find that visualizations are not showing data or that selections are not providing the expected result.  This is really noticeable if you do a Limited Load with only a few records like 5 or 10.  When using Limited Load or First, the data that is loaded may not be associated so you may end up with tables in the data model with disconnected data.  That is ok, once you do a full reload, everything will look as you expect.

Limited Load and the First prefix both can reduce the execution time of the reload script which can be helpful when you want to just test a script or when you are testing with a live data source.  There are times when you need to load all the data in order to ensure that the script logic is working – it all depends on the specific application - but it is good to know when working with large data sources that there are options that can reduce the reload time.

Thanks,

Jennell

11 Comments
Not applicable

Thanks!

0 Likes
96 Views
mrooney
New Contributor III

Very useful when developing.

Thanks Jennell.

0 Likes
96 Views

Thanks for sharing.. This blog need to be here long time before ! Anyway better late than never...:-)

0 Likes
96 Views
rajeshvaswani77
Valued Contributor III

Thanks, nice post!

0 Likes
96 Views
krishnacbe
Valued Contributor III

Nice Post!! Thanks for Sharing

0 Likes
96 Views
sunilkumarqv
Valued Contributor II

Thanks, actually its nice.

Have a question ?

what suppose we have done script changes on 25th tab?

personally i feel bring the 25th tab to first and use exist script  at last loading all fields records


Because if you limit the load for first 10 records we don't no what happen to last records

we may have use joins and several functions? 

what you say hicjmc

0 Likes
96 Views
pljsoftware
Contributor III

Usually to reduce load time and to test a single parte of code I use Exit Script and comment all part that not is necessary.

Sometimes, when I need to find error or test particular data set I use First (n) LOAD and I modify all LOAD with Exists, this give me the possibility to have data consistency.

The best practic I think is

First (10)

LOAD MyField
Where MyField = 'mycondition';

SQL Select ....;

LOAD

*

where exists (MyField);

Sql Select .....;

0 Likes
96 Views
beck110979
Valued Contributor III

Thanks Jennell,

as always very helpful and powerful

0 Likes
96 Views
PabloMC
New Contributor

Good post!

Is there any way to load all records with the FIRST prefix?

I want to control the number of records in all the script only changing a variable,

so that i can load all records changing only the variable.

for example

let MaxNum = 400;

TableA:

first $(MaxNum)

LOAD *

resident Table;

Any parameter to load everything?

thanks in advance.

0 Likes
96 Views
Not applicable

Did you ever discover how to accomplish this?  I am wanting to do the same thing and possibly use an environment variable to prevent loading millions of records on our dev box.

0 Likes
96 Views
rickwild
Contributor

Hi,

You could try changing your script to this:

let MaxNum = 'First 400';

TableA:

$(MaxNum)

LOAD *

resident Table;

When you want to load everything, let MaxNum = '';


It will confuse the script syntax check, but that may be worth it.


0 Likes
96 Views