Speed up accessing Memo & WideMemo data?

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

Speed up accessing Memo & WideMemo data?

Post by aehimself »

I have a query which is opening a table with some CLOB fields in it. I overridden the WideMemo field's gettext event so the grid will actually show the data in them, not only (BLOB).

Now here is the problem. When the gettext event is NOT assigned, displaying the grid takes ~100 ms. With gettext, it takes ~25 seconds.
I already have doCachedLobs disabled in the TZQuery object to make sure all data is available when the grid starts updating.

I guess this will have something to do with how the data is accessed in the field... as Memo and WideMemo fields create and destroy a stream object each time when Field.AsString (or Field.AsBytes) is called. And since the grid shows 30-40 of these fields...

I'll try to play around with some messy typecastings to see if they'll work but is there a way I can achieve some speedup... officially? :)
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Speed up accessing Memo & WideMemo data?

Post by EgonHugeist »

aehimself wrote: 04.11.2020, 10:06 I already have doCachedLobs disabled in the TZQuery object to make sure all data is available when the grid starts updating.
Isn't it exactly vice versa? CachedLobs are local memory lobs on client side. UnCached lobs are fetched from Server to Client on demand(If the server supports a nice api for that, such as IB/FB, Oracle, Posgres using OID-Lobs).
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
MJFShark
Expert Boarder
Expert Boarder
Posts: 211
Joined: 04.06.2020, 13:59

Re: Speed up accessing Memo & WideMemo data?

Post by MJFShark »

Are we talking Oracle? As far as I can tell the Zeos Oracle driver doesn't support the CachedLobs option. I see no difference in performance with the setting and it appears that the clob is retrieved anytime the field is accessed (and I see the same network traffic regardless of re-reads.) I also get no hits back from the source code with a search for "CachedLob" in any of the Oracle dbc files (which I do for the other drivers.)

-Mark
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Speed up accessing Memo & WideMemo data?

Post by aehimself »

EgonHugeist wrote: 04.11.2020, 16:20Isn't it exactly vice versa? CachedLobs are local memory lobs on client side. UnCached lobs are fetched from Server to Client on demand(If the server supports a nice api for that, such as IB/FB, Oracle, Posgres using OID-Lobs).
Well, I had it on Enabled until now, just switched it to disabled with little to no effect. And since yes, the RDBMS in question is Oracle I believe that Mark is right:
MJFShark wrote: 04.11.2020, 17:10As far as I can tell the Zeos Oracle driver doesn't support the CachedLobs option.
I tried as a blob field, reading out as stream / bytes / string / raw, all had the insane performance penalty.
Is there a way to tell Zeos to load WideMemo fields as WideString? Downloading the dataset will take longer, but data could be read out immediately.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Speed up accessing Memo & WideMemo data?

Post by EgonHugeist »

You guys are right, hope the quick fix of https://sourceforge.net/p/zeoslib/code-0/7033/ will resolve the issue?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Speed up accessing Memo & WideMemo data?

Post by aehimself »

Holy f*ck!

It's not visible on Git yet so I made your changes in my local repository.
Loading time of 25 seconds has been reduced to 47 ms...!
Wtf :D

Btw, doCachedLobs has no effect, as TZAbstractStatement.Create only checks for a parameter in the SQL connection:

FCachedLob := StrToBoolEx(DefineStatementParameter(Self, DSProps_CachedLobs, 'false'));

ZDbcOracleStatement checks this FCachedLob field, not paying attention to the owning dataset's options.
I'll see if I can access it somehow from there to issue a fix...

Edit: it seems that unfortunately it's not going to work this easy. The statement doesn't have a connection to a dataset, it works with the connection object directly. We'll have to introduce a new parameter in the constructor, so the dataset can pass this information when creating said statement.

But holy f*ck this speed increase... THANK YOU!
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
MJFShark
Expert Boarder
Expert Boarder
Posts: 211
Joined: 04.06.2020, 13:59

Re: Speed up accessing Memo & WideMemo data?

Post by MJFShark »

That's interesting! I've also noticed that doCachedLobs has no affect. In my testing using the session based setting I see that my query takes much longer to retrieve the result set initially (as expected since now it retrieves the CLOBs at that time) and then accessing the clobs later is super fast and cached. I'm doing a fetch all since I also show the results in a virtual grid. So that definitely seems to be working correctly although I'd love to see separate "CacheLobs" and "DeferLobs" options (so that individual lobs are cached "on demand" if both settings are on.) Unless there's some way to do that now?

-Mark
Post Reply