322
322
for a, b and c in this list.
323
323
@param conds top level item of an expression representing
324
324
WHERE clause of the top level select
325
@param og_num total number of order_st BY and GROUP BY clauses
325
@param og_num total number of ORDER BY and GROUP BY clauses
327
@param order linked list of order_st BY agruments
327
@param order linked list of ORDER BY agruments
328
328
@param group linked list of GROUP BY arguments
329
329
@param having top level item of HAVING expression
330
330
@param select_options select options (BIG_RESULT, etc)
1492
Remove the following expressions from order_st BY and GROUP BY:
1492
Remove the following expressions from ORDER BY and GROUP BY:
1493
1493
Constant expressions @n
1494
1494
Expression that only uses tables that are of type EQ_REF and the reference
1495
1495
is in the order_st list or if all refereed tables are of the above type.
1497
1497
In the following, the X field can be removed:
1499
SELECT * FROM t1,t2 WHERE t1.a=t2.a order_st BY t1.a,t2.X
1500
SELECT * FROM t1,t2,t3 WHERE t1.a=t2.a AND t2.b=t3.b order_st BY t1.a,t3.X
1499
SELECT * FROM t1,t2 WHERE t1.a=t2.a ORDER BY t1.a,t2.X
1500
SELECT * FROM t1,t2,t3 WHERE t1.a=t2.a AND t2.b=t3.b ORDER BY t1.a,t3.X
1503
1503
These can't be optimized:
1505
SELECT * FROM t1,t2 WHERE t1.a=t2.a order_st BY t2.X,t1.a
1506
SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b order_st BY t1.a,t2.c
1507
SELECT * FROM t1,t2 WHERE t1.a=t2.a order_st BY t2.b,t1.a
1505
SELECT * FROM t1,t2 WHERE t1.a=t2.a ORDER BY t2.X,t1.a
1506
SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b ORDER BY t1.a,t2.c
1507
SELECT * FROM t1,t2 WHERE t1.a=t2.a ORDER BY t2.b,t1.a
1510
1510
bool eq_ref_table(JOIN *join, order_st *start_order, JoinTable *tab)
3843
This function is used when optimizing away order_st BY in
3844
SELECT * FROM t1 WHERE a=1 order_st BY a DESC,b DESC.
3843
This function is used when optimizing away ORDER BY in
3844
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC.
3846
3846
int join_read_last_key(JoinTable *tab)
4512
4512
Skip key parts that are constants in the WHERE clause.
4513
These are already skipped in the order_st BY by const_expression_in_where()
4513
These are already skipped in the ORDER BY by const_expression_in_where()
4515
4515
for (; const_key_parts & 1 ; const_key_parts>>= 1)
4971
4971
bool is_covering= table->covering_keys.test(nr) || (nr == table->s->primary_key && table->cursor->primary_key_is_clustered());
4974
Don't use an index scan with order_st BY without limit.
4974
Don't use an index scan with ORDER BY without limit.
4975
4975
For GROUP BY without limit always use index scan
4976
4976
if there is a suitable index.
4977
4977
Why we hold to this asymmetry hardly can be explained
5156
5156
return 0; // Use filesort
5159
/* order_st BY range_key DESC */
5159
/* ORDER BY range_key DESC */
5160
5160
tmp= new optimizer::QuickSelectDescending((optimizer::QuickRangeSelect*)(select->quick),
5161
5161
used_key_parts,
5174
5174
tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
5177
SELECT * FROM t1 WHERE a=1 order_st BY a DESC,b DESC
5177
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
5179
5179
Use a traversal function that starts by reading the last row
5180
5180
with key part (A) and then traverse the index backwards.
5605
5605
*****************************************************************************/
5608
Resolve an order_st BY or GROUP BY column reference.
5608
Resolve an ORDER BY or GROUP BY column reference.
5610
5610
Given a column reference (represented by 'order') from a GROUP BY or order_st
5611
5611
BY clause, find the actual column it represents. If the column being
5612
5612
resolved is from the GROUP BY clause, the procedure searches the SELECT
5613
5613
list 'fields' and the columns in the FROM list 'tables'. If 'order' is from
5614
the order_st BY clause, only the SELECT list is being searched.
5614
the ORDER BY clause, only the SELECT list is being searched.
5616
5616
If 'order' is resolved to an Item, then order->item is set to the found
5617
5617
Item. If there is no item for the found column (that is, it was resolved
6199
6199
itr.sublist(res_selected_fields, elements);
6201
Put elements from HAVING, order_st BY and GROUP BY last to ensure that any
6201
Put elements from HAVING, ORDER BY and GROUP BY last to ensure that any
6202
6202
reference used in these will resolve to a item that is already calculated
6204
6204
param->copy_funcs.concat(&extra_funcs);