Pre-Define Database Table

53 views
Skip to first unread message

matt smith

unread,
Dec 29, 2013, 1:45:36 PM12/29/13
to f3-fra...@googlegroups.com
A part of my web app requires maximum performance. I notice when I use anything other than $db->exec, F3 makes a SHOW columns call. I realize why it's doing that. What I wanted to know though is can I define a class which describes the table, so a SHOW columns call is not necessary?

I also tried the Cortex add-on and have the table defined in a class, but it also still makes a SHOW columns call.

I know that such calls can get cached by mysql, I would still like to alleviate the unnecessary overhead since my schema will not be changing. Also, while we're at it, can you tell F3 to only bring back certain fields?

Thanks.


bcosca

unread,
Dec 29, 2013, 3:33:54 PM12/29/13
to f3-fra...@googlegroups.com
A part of my web app requires maximum performance. I notice when I use anything other than $db->exec, F3 makes a SHOW columns call. I realize why it's doing that. What I wanted to know though is can I define a class which describes the table, so a SHOW columns call is not necessary?

I also tried the Cortex add-on and have the table defined in a class, but it also still makes a SHOW columns call.

The 4th argument of the SQL mapper constructor is a TTL to give the schema detector a hint about how often a SHOW COLUMNS call is issued.
 
I know that such calls can get cached by mysql, I would still like to alleviate the unnecessary overhead since my schema will not be changing. Also, while we're at it, can you tell F3 to only bring back certain fields?

The SQL mapper has a 3rd argument for specifying only the fields you need.

Emmanuel

unread,
Dec 29, 2013, 3:50:54 PM12/29/13
to f3-fra...@googlegroups.com
can you tell F3 to only bring back certain fields?


$columns = $db->schema('mytable', 'name;age'); // only interested in these 2 columns

 

ikkez

unread,
Dec 29, 2013, 8:19:37 PM12/29/13
to f3-fra...@googlegroups.com
When you enable the CACHE, those show columns calls are all cached for 60sec by default.

matt smith

unread,
Dec 29, 2013, 8:22:43 PM12/29/13
to f3-fra...@googlegroups.com
Thanks for the cache info. That's good to know.

I also noticed that after an INSERT (Save) that a SELECT call is made. Is there a way to prevent that SELECT call being made? When I'm inserting analytics at a fast clip, I would like it to just make the INSERT call and not anything unnecessary for that scenario.

Thanks again.

bcosca

unread,
Dec 29, 2013, 8:30:21 PM12/29/13
to f3-fra...@googlegroups.com
That SELECT call is for determining the lastinsertrecord() and there isn't a way of getting around that if you have an autoincrement field.

matt smith

unread,
Dec 29, 2013, 9:19:10 PM12/29/13
to f3-fra...@googlegroups.com
In cursor.php, the load function doesn't support passing a TTL. Is there a rationale for this?

I modified it and cortex.php's load function to support taking TTL and passing it to find and it works fine, but I don't know if you want to add this in there or not, since I'm not sure why it's not currently supported.

Thanks.

bcosca

unread,
Dec 29, 2013, 9:28:36 PM12/29/13
to f3-fra...@googlegroups.com
Code improvements in the form of Git pull requests are welcome and much appreciated.

bcosca

unread,
Dec 29, 2013, 9:32:24 PM12/29/13
to f3-fra...@googlegroups.com
Anyway, this oversight has been committed to the repo. See dev branch.

matt smith

unread,
Dec 29, 2013, 9:37:36 PM12/29/13
to f3-fra...@googlegroups.com
I was just getting it together. You're too fast :-). Thanks for adding that.
Reply all
Reply to author
Forward
0 new messages