mySQL 4 Compress Option

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
nicholsonjohn
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 12.02.2006, 18:24

mySQL 4 Compress Option

Post 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
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post 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.. :):):)
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post 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.. :)
nicholsonjohn
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 12.02.2006, 18:24

Post 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.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Good idea!For Linux no problem (tcpdump), but for Wins?
anse123
Junior Boarder
Junior Boarder
Posts: 26
Joined: 23.02.2006, 22:28

Post 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.
anse123
Junior Boarder
Junior Boarder
Posts: 26
Joined: 23.02.2006, 22:28

Post 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
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

So, how do we enable compression..? :):):):):)
IgD
Zeos Dev Team
Zeos Dev Team
Posts: 43
Joined: 15.10.2005, 07:18
Location: Okinawa, Japan
Contact:

Post 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;
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
You do not have the required permissions to view the files attached to this post.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

mdaems, you really rock!... :)

Have you everm tought to join the developer team..? :)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post 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.
TheBroker
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 06.11.2007, 19:25

Post 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:
Post Reply