Postgres provides support for custom tablesamplers as part of the SELECT statement.
ZomboDB provides three different table sampler implementations that allow you to sample a table using a simple text-search query, Elasticsearch's "sampler" aggregate and "diversified_sampler" aggregations.
TABLESAMPLE zdb.query_sampler(index_name regclass, query zdbquery)
This is the simplest table sampler that simply returns all the rows that match the specified query. Its results are stable per run, regardless of the REPEATABLE(seed)
option.
TABLESAMPLE zdb.sampler(index_name regclass, shard_size int, query zdbquery)
This table sampler uses Elasticsearch's sampler aggregation to sample the specified index using a specific shard size and query.
Per the Elasticsearch documentation, a few example uses cases for this sampler might be
zdb.significant_terms()
aggregation)An example usage might be:
SELECT *
FROM table
TABLESAMPLE zdb.sampler('idxtable', 200, 'tags:postgres OR tags:sql');
The table sampler can, of course, be combined with a WHERE clause so that you're then searching the results of the sample:
SELECT *
FROM table
TABLESAMPLE zdb.sampler('idxtable', 200, 'tags:postgres OR tags:sql')
WHERE table ==> 'zombodb';
The results are stable per run, regardless of the REPEATABLE(seed)
option.
TABLESAMPLE zdb.diversified_sampler(index_name regclass, shard_size int, common_field_name text, query zdbquery)
This table sampler uses Elasticsearch's diversified sampler aggregation to sample the specified index.
Per the Elasticsearch docs, this sampler can be used in siutations where you want to
zdb.significant_terms()
aggregation)An example usage might be:
SELECT *
FROM table
TABLESAMPLE zdb.diversified_sampler('idxtable', 200, 'author', 'tags:postgres OR tags:sql');
The table sampler can, of course, be combined with a WHERE clause so that you're then searching the results of the sample:
SELECT *
FROM table
TABLESAMPLE zdb.diversified_sampler('idxtable', 200, 'author', 'tags:postgres OR tags:sql')
WHERE table ==> 'zombodb';
The results are stable per run, regardless of the REPEATABLE(seed)
option.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。