I am using stringgrid component instead of dbgrid for displaying query result, but when I have big result query it takes a lot of time to fill the stringgrid. If I switch to dbgrid, this happened much much faster. So, how to fill stringgrid with query result as fast as possible?
Thanks.
ZeosLIb and stringgrid?
Moderators: gto, cipto_kh, EgonHugeist
I expect it's a limitation of the stringgrid. Try looking for a different component e.g. Virtual Treeview (http://www.soft-gems.net/index.php?opti ... &Itemid=33could do what you want but takes a little effort to program for.
Regards,
Ben
Regards,
Ben
-
- Fresh Boarder
- Posts: 4
- Joined: 08.09.2006, 18:03
I figured out that the problem is not in stringgrid. I tryed to generate stringgrid of 100000x10 cells with some random text and the speed is quite OK. So the problem is with reading database. I am using (for reading) ZQuery with function next, (then read data), next (then read data).... is there any fastest way for reading from query?
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi,
Reading that many rows is quite heavy indeed. I see 3 options:
- Try to use the zeos dbc layer directly. This avoids some of the TDataset handling. You'll have to look around a little to find nice examples. They exist, but don't ask me where.
- Try to only load the data actually visible. So only when scrolling down you load data not visible at first. Still slow when jumping to the last record is possible.
- Ask the database to concatenate multiple rows. So you only have to read one database record to to fill multiple grid rows. How? group_concat in mysql, stored procs to do the editing on database side (eg by preparing xml files you can parse when filling the grid.)
Of course : you should first check if the query is not delaying everything.
Mark
BTW : with 100000 lines you can fill a heavy book. Who ever reads this from a string grid? Make sure you only show the data that the user is looking for.
Reading that many rows is quite heavy indeed. I see 3 options:
- Try to use the zeos dbc layer directly. This avoids some of the TDataset handling. You'll have to look around a little to find nice examples. They exist, but don't ask me where.
- Try to only load the data actually visible. So only when scrolling down you load data not visible at first. Still slow when jumping to the last record is possible.
- Ask the database to concatenate multiple rows. So you only have to read one database record to to fill multiple grid rows. How? group_concat in mysql, stored procs to do the editing on database side (eg by preparing xml files you can parse when filling the grid.)
Of course : you should first check if the query is not delaying everything.
Mark
BTW : with 100000 lines you can fill a heavy book. Who ever reads this from a string grid? Make sure you only show the data that the user is looking for.