List:Internals« Previous MessageNext Message »
From:Zhixuan Zhu Date:May 11 2009 4:54pm
Subject:How to get all fields used in a select query
View as plain text  
Hello,

We're writing a custom storage engine which is column based. We want to
avoid returning all columns of each table back to MySQL because some
columns in our schema are blobs (comment columns) and they're not
generally used. Plus since we're column based engine, the less number of
columns we have to return, the more efficient it will be. 

So my question is: is there a way to get all the fields (item_fields)
that are used in the query? They should include select list, where,
having, group by, order by clause, subquery, and everything. Currently
we're getting all select columns from select_lex.item_list. We then
parse select_lex.join->conds to get the where clause columns. After that
we get group by, order by, having clause columns by iterate group_list,
order_list and having of select_lex. Besides the complexity of this
solution, we're most concerned that some columns might be left out
because we still can not interpret all the item types on the cond tree
(like ref item) and we'll drop whatever we don't understand. We'll
simply return NULL for the columns we drop. Thus MySQL will give a wrong
result based on the NULL columns that it actually expects result back.

The version we're using is 5.1.26 built from source. Any insights,
suggestions and comments are most appreciated. Thanks in advance.

Sincerely,
Zhixuan

Thread
How to get all fields used in a select queryZhixuan Zhu11 May
  • Re: How to get all fields used in a select queryKristian Nielsen11 May
    • RE: How to get all fields used in a select queryZhixuan Zhu11 May