在Postgresql数据库中跨边界查找分区

编程入门 行业动态 更新时间:2024-10-26 20:27:19
本文介绍了在Postgresql数据库中跨边界查找分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何通过该分区的范围(边界)信息在数据库目录中找到该分区? 我使用日期字段对表进行了分区,我需要通过该信息查找分区。 我已经看到目录 child表中有一个 relpartbound字段,但这似乎并不是一种简单的搜索方法。

How can I find a partition in the database catalog through the range (bounds) information of that partition? I partitioned a table using a date field and I need to find a partition through that information. I've seen that I have a "relpartbound" field in the catalog "child" table, but it does not seem to be in an easy way to search.

推荐答案

SELECT nmsp_parent.nspname AS parent_schema, parent.relname AS parent, nmsp_child.nspname AS child_schema, child.relname AS child, pg_get_expr(child.relpartbound, child.relfilenode) AS child_bounds FROM pg_inherits JOIN pg_class parent ON pg_inherits.inhparent = parent.oid JOIN pg_class child ON pg_inherits.inhrelid = child.oid JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace WHERE parent.relname = 'parent_table_name';

PostgreSql函数 pg_get_expr将反编译 child.relpartbound表达式的内部形式并给我一些东西更多readble像:

PostgreSql function "pg_get_expr" will decompile internal form of "child.relpartbound" expression and will give me something more readble like:

FOR VALUES FROM ('2017-01-01') TO ('2017-01-02')

Ty @a_horse_with_no_name是个很好的建议。

Ty @a_horse_with_no_name for the great suggestion.

更多推荐

在Postgresql数据库中跨边界查找分区

本文发布于:2023-10-20 03:38:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1509729.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边界   数据库中   分区   Postgresql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!