List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:July 4 2011 7:41am
Subject:Re: bzr commit into mysql-trunk branch (magnus.blaudd:3187) WL#5906
View as plain text  
Hi, Magnus!

 On 06/10/2011 12:26 PM, magnus.blaudd@stripped wrote:
>   3187 magnus.blaudd@stripped	2011-06-10
>        WL#5906 read before write removal (RBWR)
>         - Make it possible for storage engines to optimize away
>           read of record before UPDATE/DELETE in order to save
>           roundtrips and allow for batching.

May I chime in?

Generally, it doesn't look like something that needs new methods in the
handler class - this perfectly fits in the existing API.

You don't need to read records before deleting or updating when the
server does not need old values, e.g. for WHERE or for calculating new
values, right?

But if there's no WHERE in DELETE, the server will use
handler::delete_all_rows() and won't read any rows.
Of course, for most practical cases there will be WHERE, but you push it
down to the engine and MySQL may think there's no WHERE.

For UPDATE it's similar - no WHERE condition in the server (because it's
pushed down) and empty TABLE::read_set bitmap, in this case the server
should read no rows. The engine only needs to manipulate
HA_PRIMARY_KEY_REQUIRED_FOR_DELETE properly to enable this optimization.

What am I missing?

> === modified file 'sql/handler.h'
> --- a/sql/handler.h	2011-06-01 09:11:28 +0000
> +++ b/sql/handler.h	2011-06-10 10:24:29 +0000
> @@ -1796,6 +1796,28 @@ public:
>     virtual int extra_opt(enum ha_extra_function operation, ulong 
> cache_size)
>     { return extra(operation); }
>
> +  /*
> +    Informs the handler if this handler support read removal
> +    (could use table_flags, but patch is smaller this way)
> +   */
 > +
> +  virtual bool read_before_write_removal_supported(void) const
> +  { return false;
>
> +  /*
> +    Informs handler that it is possible to optimise away the real read
> +    operation from the handler for the current table and instead
> +    use a generated read to optimise simple UPDATE and DELETEs.
> +  */
 > +
> +  virtual bool read_before_write_removal_possible(void)
> +  { return false; }
>
> +  /*
> +    Return the number of rows the handler has written while using
> +    read before write removal
> +   */
> +  virtual ha_rows read_before_write_removal_rows_written(void) const
> +  { DBUG_ASSERT(0); return (ha_rows) 0; }
>
Regards,
Sergei
Thread
Re: bzr commit into mysql-trunk branch (magnus.blaudd:3187) WL#5906Jon Olav Hauglid4 Jul
  • Re: bzr commit into mysql-trunk branch (magnus.blaudd:3187) WL#5906Sergei Golubchik4 Jul