PostgreSQL程式碼分析,查詢最佳化部分,pull_ands()和pull_ors()

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   ar   for   

PostgreSQL程式碼分析,查詢最佳化部分。


這裡把正式指令動詞運算式的部分就整理完了,閱讀的順序例如以下:

一、PostgreSQL程式碼分析,查詢最佳化部分,canonicalize_qual

二、PostgreSQL程式碼分析,查詢最佳化部分,pull_ands()和pull_ors()

三、PostgreSQL程式碼分析,查詢最佳化部分,process_duplicate_ors


*************************************************************************************************************************************************************


pull_ands()和pull_ors()的代碼比較便於理解,就是把樹狀結構的AND操作拉平,是pull_ands的範例,pull_ors邏輯同樣:




/* * pull_ands *  Recursively flatten nested AND clauses into a single and-clause list. * * Input is the arglist of an AND clause. * Returns the rebuilt arglist (note original list structure is not touched). */static List *pull_ands(List *andlist){List   *out_list = NIL;ListCell   *arg;foreach(arg, andlist){Node   *subexpr = (Node *) lfirst(arg);/* * Note: we can destructively concat the subexpression's arglist * because we know the recursive invocation of pull_ands will have * built a new arglist not shared with any other expr. Otherwise we'd * need a list_copy here. */if (and_clause(subexpr))out_list = list_concat(out_list,   pull_ands(((BoolExpr *) subexpr)->args));elseout_list = lappend(out_list, subexpr);}return out_list;}/* * pull_ors *  Recursively flatten nested OR clauses into a single or-clause list. * * Input is the arglist of an OR clause. * Returns the rebuilt arglist (note original list structure is not touched). */static List *pull_ors(List *orlist){List   *out_list = NIL;ListCell   *arg;foreach(arg, orlist){Node   *subexpr = (Node *) lfirst(arg);/* * Note: we can destructively concat the subexpression's arglist * because we know the recursive invocation of pull_ors will have * built a new arglist not shared with any other expr. Otherwise we'd * need a list_copy here. */if (or_clause(subexpr))out_list = list_concat(out_list,   pull_ors(((BoolExpr *) subexpr)->args));elseout_list = lappend(out_list, subexpr);}return out_list;}

張大明確的blog:http://blog.csdn.net/shujiezhang


PostgreSQL程式碼分析,查詢最佳化部分,pull_ands()和pull_ors()

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.