cmu-db / peloton

The Self-Driving Database Management System
http://pelotondb.io
Apache License 2.0
2.03k stars 623 forks source link

Apply limit + order optimization in the optimizer #1385

Closed chenboy closed 6 years ago

chenboy commented 6 years ago

This PR applies limit + sort optimization in the optimizer as the same way ORCA does it. Basically, we keep an internal order in Limit operator when the parse tree contains both limit and order, and the optimizer logic is tweaked a bit to consider this internal sort. When the plan is generated, the limit operator will generate a LimitPlan on top of an OrderByPlan with limit and offset set correctly.

The multiple test cases in optimizer_sql_test.cpp already tested order by with limit, so I didn't add new ones.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.05%) to 77.903% when pulling 292aa80ae67117e3537c24b147b973ee6cbb095c on chenboy:limit_fix into bf7ff625e86f2917bc939f85c41e810eec3588ec on cmu-db:master.

apavlo commented 6 years ago

Thanks! Let's have @malin1993ml review this.

linmagit commented 6 years ago

I'll review this after I get back to hotel.

apavlo commented 6 years ago

@malin1993ml @GustavoAngulo Since @chenboy is now at Snowflake, I think that you guys will need to take care of this. Can you fix it by next week. We are going to need this for TPC-C (AFAIK)

chenboy commented 6 years ago

Oh, I nearly forgot this, sorry. I'll address comments & fix the code tonight.

linmagit commented 6 years ago

Thanks a lot, Bowei!

On Thu, Jun 21, 2018 at 11:49 AM, Bowei Chen notifications@github.com wrote:

Oh, I nearly forgot this, sorry. I'll address comments & fix the code tonight.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cmu-db/peloton/pull/1385#issuecomment-399206129, or mute the thread https://github.com/notifications/unsubscribe-auth/AFojzUgsexj-YjMN8X4cbC3s2D3dRCalks5t--rSgaJpZM4UPLdL .

tli2 commented 6 years ago

@malin1993ml Jenkins has been wonky lately. Restarting fixed it.