← Back to team overview

maria-developers team mailing list archive

Re: Help with MDEV-4419, ENUM optimization

 

i was reading file "opt_range.cc", but i'm a bit confused (maybe first
impression)
where the per column check occurs?
where the "Impossible WHERE" condiction occurs?
--------------------------------------

i'm thinking about a implementation like this (per column):

field = ENUM field
WITH enum_values[i], where i start with 0 to ENUM VALUES + 1,

example:
field ENUM ( 1,2,3,4,5,6 ) NOT NULL
max i = 6
field ENUM ( 1,2,3,4,5,6 )
max i = 7

enum_value[0]=1,
enum_value[1]=2,
enum_value[2]=3,
enum_value[3]=4,
enum_value[4]=5,
enum_value[5]=6
enum_value[6]='' -> this allow insert of 10000 value in this field
enum_value[7]=NULL -> if ENUM accept NULL add +1


-------------------------------------
OP could be: =,!=,<>,<,<=,>,>=

(field OP constant_value)

REWRITE TO

(
 (field OP constant_value) AND
 (
   enum_value[0] OP constant_value OR
   enum_value[1] OP constant_value OR
   ...
   enum_value[max i - 1] OP constant_value OR
   enum_value[max i] OP constant_value
 )
)
-------------------------------------
(OP BETWEEN a AND b)

REWRITE TO

(
 (field BETWEEN constant_value_1 AND constant_value_2) AND
 (
   (enum_value[0] BETWEEN constant_value_1 AND constant_value_2) OR
   (enum_value[1] BETWEEN constant_value_1 AND constant_value_2) OR
   ...
   (enum_value[ max i - 1 ] BETWEEN constant_value_1 AND constant_value_2)
OR
   enum_value[ max i ] OP constant_value
 )
)
-------------------------------------

Follow ups

References