Page 1 of 1

mySQL 4 Compress Option

Posted: 13.02.2006, 08:14
by nicholsonjohn
Does anyone know if it's possible to turn on the mySQL 'Compress' option from within a Delphi (V6)/Zeoslib application? If I set it in the my.ini file then the mysql console will use compression when speaking to the server but it has no effect on my application.

thanks
john n

Posted: 13.02.2006, 14:23
by zippo
Read the "documentation/parameters.htm" file.

I once tried to use the Properties property of ZConnection like this:

compress=yes

but It didn't worked. Maybe a developer could enlighten us.. :):):)

Posted: 13.02.2006, 14:38
by zippo
Another question - How to know if the compression is on or off? Because there's no error, I can't tell if it works or not.. :)

Posted: 01.04.2006, 18:10
by nicholsonjohn
zippo wrote:Another question - How to know if the compression is on or off? Because there's no error, I can't tell if it works or not.. :)

If you use a sniffer to look at the data on the network you will see it is unreadable if compression is on.

Posted: 01.04.2006, 18:42
by zippo
Good idea!For Linux no problem (tcpdump), but for Wins?

Posted: 29.04.2006, 20:43
by anse123
The Unit ZDBCMySQL reads and sets the option "compress" on the "Open"-procedure:

Code: Select all

procedure TZMySQLConnection.Open;
...
{ Turn on compression protocol. }
if StrToBoolEx(Info.Values['compress']) then
  FPlainDriver.SetOptions(FHandle, MYSQL_OPT_COMPRESS, nil);
{ Sets connection timeout. }
ConnectTimeout := StrToIntDef(Info.Values['timeout'], 0);
if ConnectTimeout >= 0 then
begin
  FPlainDriver.SetOptions(FHandle, MYSQL_OPT_CONNECT_TIMEOUT,
    PChar(@ConnectTimeout));
end;
{ Connect to MySQL database. }
if StrToBoolEx(Info.Values['dbless']) then
begin
...
The big question is, what is this "Info" and where is it set? Maybe it IS the properties-Property as Zippo said but who knows? So far I made the same experiance - didn't work at all if I set timeout or compress in properties.

Posted: 29.04.2006, 20:48
by anse123
Aahhh....

It really seems to be the Properties of the ZConnection. Try to set

Code: Select all

compress=1
and then, after being connected, execute this SQL-command:

Code: Select all

show status like "compr%"
It correspondents with the value set in the properties!

And the good info: We now know that the "Info"-list IS the properties and there are some other interesting properties like "dbless" to find in the open-procedure. :D

Greetings,
Anse

Posted: 29.04.2006, 22:00
by zippo
So, how do we enable compression..? :):):):):)

Posted: 29.04.2006, 22:19
by IgD
I use compression with MySQL 5. There are MySQL functions called COMPRESS() and UNCOMPRESS(). Basically you just make these calls in your SQL queries.

For example:
select UniqueID, uncompress(MyString) from MyTable;
or
select UniqueID, uncompress(MyString) as UncompressedMyString from MyTable;

Posted: 30.04.2006, 00:09
by mdaems
Hi IGD,

I think these function do not change the connection behaviour in general. It just works for specific data you want to compress for whatever reason.

To theothers

When we are discussing the Info/Properties stuff : Some weeks ago I did modify the code shown by anse123 to include all clientflags currently provided by the mysql API. This modifications are in SVN testing branch. Please test them when you are working with this compression option.

BTW : according to mysql doc this compression only works when both server and client dll support it.

Just tested. Test project (initially made for the modifications mentioned above) is included. Hope it works for you. D7 and mysql5. You will have to change your connection parameters and can play with the properties property of the connection to see the result.

Mark

Posted: 30.04.2006, 10:21
by zippo
mdaems, you really rock!... :)

Have you everm tought to join the developer team..? :)

Posted: 01.05.2006, 22:45
by mdaems
Zippo,
Thanks for the compliment.

Yes I did, and you're not the first to ask. But, for the moment, I prefer to do the work on an volunteer base. What means : if I have time between spouse, kids, work, music playing, red cross activities,... I just look at the forum and see if there's something interesting to look at. If I'd become an official developer, there's (in my opinion) to much obligation to the part I would be assigned to. The more, I'm not a real Delphi developer. For work I'm a cobol/mainframe or Oracle developer. So I don't have any OO background. We'll see how everything goes on... (BTW, why's your status still 'just' senior boarder :wink: )

Mark

Posted: 01.05.2006, 22:51
by zippo
Because I'm jusk like you :) I like to help people and get very happy when others do the same for me, just as you did with MySQL temp tables. You really saved me ... :)

I'm very satisfied that Zeos is beginning to gear again and I see myself as a supporter for Zeos users.

Posted: 06.11.2007, 19:37
by TheBroker
For activate the cliente compression protocol (more faster and securely) only you must add to the properties the next line:

compress=true

Not compress=on!!

Example:

Code: Select all

zeosConnection.Properties.Add('compress=true');
This property have effect in a new zeoslib connection (do not work with reconnect).

This property only work with some RDBMS like MySQL.

Before to test check that ZConnection.Connected is false. :wink: