Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Same SQL Select takes 5 minutes or 2 seconds!
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01501481
Message ID:
01501491
Views:
57
Sergey

Thanks for responding to my posting.

I'm not quite sure what you are asking. But let me take a stab.

The Firebird database is actually on the same computer during development. Later it may be on the same computer, or another computer in the network. In either case, I'm using Firebird ODBC driver to make the connection.

But, I don't believe the problem I'm having has to do with interacting with the Firebird tables themselves. Since once I invoke vPatients, the data are right there in VFP. Right? In any case.....

1. I Create SQL View vPatients, etc. - this may take 25 seconds.

2. Later: USE vPatients in 0 to invoke the view - this make take 45 seconds

3. Then, in the form refresh method, my SQL Select statement: first time takes 5 minutes. Subsequent Refresh calls: instantaneous. But, always it is the same SQL Select statement.

Jim



>How long does it take to run the View SQL directly against Firebird table the first and subsequent times?
>
>
>>My application instantiates a view into a Firebird table, then uses a SQL Select statement to create a cursor that populates a grid.
>>
>>The SQL select statement is located in the form refresh method.
>>
>>In the form Init method, I invoke the view, and then call the form refresh method which populates the grid. The time to execute the SQL Select in the form refresh method the first time takes around 5 minutes! (MessageBox statements before and after the SQL Select allow me to measure the execution time.)
>>
>>When the form apepars, I can click on a column heading to resort the grid on that column. My code for that sets a grid property to the name of the column on which to sort, and then calls the form refresh to repopulate the grid. This time exectuion of the SQL Select is instantaneous.
>>
>>Here is the relevant code in my form refresh method:
>>
>>
>>WITH this.grdPatients
>>	.RecordSource = SPACE(0)
>>	.RecordSourceType = 1
>>	lcCursorName = .cCursorName
>>	lcSQLSortColDirection = .cSQLSortCol + ' ' + .cSQLSortDirection
>>	SELECT USR_NAME, USR_FIRSTNAME, CAST(USR_DATEBIRTH AS DATE), USR_PatientID, USR_CITY, PatientNo ;
>>		FROM vPatients INTO CURSOR (lcCursorName) ORDER BY &lcSQLSortColDirection
>>	.RecordSource = (lcCursorName)
>>	.refresh
>>ENDWITH
>>
>>
>>
>>cSQlSortCol and cSQLSortDirection are set initially in the form designer, and updated by the colum header click method.
>>Invoking the view in the Init method takes around 1 minute. The view doesn't change for the life of the form.
>>
>>Why is the SQL Select taking so long initially, and later is instantaneous?
>>
>>Thanks in advance for your help.
>>
>>Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform