PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors()
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors(),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2048字,纯文字阅读大概需要3分钟。
内容图文

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)); else out_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)); else out_list = lappend(out_list, subexpr); } return out_list; }
张大明确的blog:http://blog.csdn.net/shujiezhang
原文:http://www.cnblogs.com/hrhguanli/p/4000074.html
内容总结
以上是互联网集市为您收集整理的PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors()全部内容,希望文章能够帮你解决PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors()所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。