Optimization of TableFound function

4 views
Skip to first unread message

Alexander Obuhovich

unread,
Oct 22, 2011, 5:21:32 PM10/22/11
to In-Portal Development
Class kDBConnection has TableFound function, that does "SHOW TABLES LIKE TableName" each time it is called with a new table name.

There are 2 ways of improving it:
  1. get list of all tables on first function call and then do in_array on every repeated call
  2. get list of all tables during unit config cache rebuild and save it into file (save 1 db query on each function call) and then only open that file and search for needed table.


--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry A.

unread,
Oct 22, 2011, 7:15:47 PM10/22/11
to in-por...@googlegroups.com
Hi Alex,


I am for 1st option when we get all tables and then do in_array. I think it's more reliable. Any cons for this approach?


Thanks.

DA

Alexander Obuhovich

unread,
Oct 23, 2011, 4:39:11 AM10/23/11
to in-por...@googlegroups.com
I'm for 2nd approach, since new tables are not added every day and usually they are added along with new units.

Also 2nd approach is 1st approach + don't use "SHOW TABLES" query at all. But if you want to check for a temporary table presence, then it will fail.


The goal of optimization was to quickly detect if module-specific database tables exists and perform associated action. However we can check for module presence directly without asking a database.

Dmitry A.

unread,
Oct 23, 2011, 2:00:03 PM10/23/11
to in-por...@googlegroups.com
Hi Alex,


I see your point, but do we really loose so much time/performance on this minor single query alone? We still would need to parse that flat file into PHP so it can be checked against, not sure if it's really worth going this direction just to check if module is installed / enabled.

May be it's sufficient enough to look at the record in Modules table which still needs to be loaded + has less records in there.

What do you think?


DA.

Alexander Obuhovich

unread,
Oct 23, 2011, 3:48:36 PM10/23/11
to in-por...@googlegroups.com
Yes, I understood that already.

Dmitry A.

unread,
Nov 1, 2011, 11:27:01 PM11/1/11
to in-por...@googlegroups.com
New task created:

1154: Optimization of TableFound function


DA
Reply all
Reply to author
Forward
0 new messages