On Mon, Mar 22, 2010 at 1:05 PM, Toru Maesaka <[email protected]> wrote:
> Hi!
>
> Would it make sense to have an engine-level option to tell the
> optimizer to prioritize index use at all times? Something along the
> line of HA_PRIORITIZE_INDEX.

Hi Toru! By "prioritize" I'm assuming you mean "always prefer an index
scan over a table scan"?

Or do you mean something else?

> I'm saying this because the relationship between
> Cursor::records_in_range() and HA_READ_RANGE seems important to
> effectively perform range scans at the moment. I tried purposely
> returning a constant small cost factor in records_in_range() but it
> seems that the range search will fail if the number of estimated rows
> (in my case a total lie) is significantly smaller than the number of
> actual rows in the table. If I don't set, HA_READ_RANGE then it seems
> Drizzle will resort to a table scan (despite knowing that
> 'possible_keys' exist in EXPLAIN).
>
> Preferably, I don't want to count through the number of rows in a
> range for the optimizer on every simple query. Although... a
> completely dishonest implementation of records_in_range() would dirty
> the EXPLAIN statement result. So there is definitely a downside to
> what I was experimenting with.

Actually, this is precisely what InnoDB does. :(  Not only does this
result in a call to malloc() for a copy of the MySQL key value
coverted into InnoDB's internal format, but it also results in a new
InnoDB mem_heap allocation and a call to
btr_estimate_n_rows_in_range().  For *every* call to
Cursor::records_in_range().

Not exactly efficient...I agree that the interface and implementation
could be much simpler and cleaner.

-jay

> It would be great to hear what you all think :)
>
> - Toru
>
> _______________________________________________
> Mailing list: https://launchpad.net/~drizzle-discuss
> Post to     : [email protected]
> Unsubscribe : https://launchpad.net/~drizzle-discuss
> More help   : https://help.launchpad.net/ListHelp
>

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to