Index Help Neede

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Beast Power
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 08.10.2014, 22:30

Index Help Neede

Postby Beast Power » 08.10.2014, 22:49

I am new to MySql and Zeos, I have a app thet connects to a MySql Database and everything works fine except some of the functions are very slow as I use a ztable.locate command to find records.

What I need is to know is what is the equivalent of the TTable.Indexname and TTable.Findkey Command with the zeos library ? (Have searched but really need help now)

User avatar
Sergiomaster
Fresh Boarder
Fresh Boarder
Posts: 22
Joined: 13.06.2011, 12:37

Re: Index Help Neede

Postby Sergiomaster » 22.10.2014, 06:18

Hello,

Findkey is a 'bad habit IMO , findkey is looking in the loaded dataset (that was great with a paradox table, loaded in memory , but not for a table in a SGBD overall if not local)
Use a ZQuery (or TZReadOnlyQuery) with a select containing a where clause .

i.e

Code: Select all

SELECT * FROM  CUSTOMERS WHERE IDNUMBER=:N

Where N is a parameter and IDNUMBER is one of the Index (not necessary but better) primary or not , unique (preferably or not)

usage

Code: Select all

TZReadOnlyQuery.Active:=False;
TZReadOnlyQuery.ParambyName('N').asINteger:=100;
TZReadOnlyQuery.Active:=True;
if TZReadOnlyQuery.FieldByName('IDNUMBER').isnull
  then showmessage('Not found')
  else .....
Main uses Delphi3/7/2010/XE4 + Interbase/Firebird


Return to “MySQL”

Who is online

Users browsing this forum: No registered users and 1 guest