TSQLQuery and fetchrow property?! lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2019-11-04 14:30 Hi guys, I'll probably ask a stupid question, but I've always used zeoslib to work with databases. Now I would like to start a new project using the typical components of lazarus. In zeoslib the TZQuery object has a propriety named fetchrow that if set> 0 loads the content of a dbgrid faster. For example, if set to 50, he loads 50 records at a time, he does not wait for the dataset to be loaded completely to draw the dbgrid. What is the correspondence in TSQLQuery? ---------------------------------------------------------------------- Zvoni · 2019-11-04 15:08 Not sure there is one. If you think about it, it's more a function of the SQL-dialect used by the Database. What you're describing would be on MySQL: SELECT SomeColumn FROM SomeTable WHERE Name='SomeName' LIMIT 50 on MSSQL: SELECT TOP 50 SomeColumn FROM SomeTable WHERE Name='SomeName' on DB2: SELECT SomeColumn FROM SomeTable WHERE Name='SomeName' FETCH FIRST 50 ROWS ONLY The implemenation would be different for different Databases. ---------------------------------------------------------------------- xinyiman · 2019-11-04 15:11 I think I understand, it would seem that the parameter is PacketRecords. But it seems that you only load the first N records, then when I browse the dbgrid it loads them all. I don't understand if you load them N at a time or just need to load the first N records faster, and then the others do them at once. ---------------------------------------------------------------------- Thaddy · 2019-11-04 15:22 Fetching all or too many records kills your application. That's why. ---------------------------------------------------------------------- Zvoni · 2019-11-04 15:22 Thx, i was looking for that Property too. As i understood it: it loads N at a time QuoteFor performance reasons, SqlDB does not read all records when opening TSQLQuery by default, only the first 10. Only when the eleventh record is accessed will the next set of 10 records be loaded, etc. But: QuoteAn alternative is available. The number of records returned by the server is set by the '.PacketRecords' property. The default value is 10; if you make it -1 then all records will be loaded at once.