Index Help Neede

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

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

Index Help Neede

Post by Beast Power »

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: 24
Joined: 13.06.2011, 12:37

Re: Index Help Neede

Post by Sergiomaster »

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/Rio 10.3/Sidney 10.4 + Interbase/Firebird
Post Reply