You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
customer_reviews_cstore: FOREIGN TABLE(partitioned by product_group)
table_type
cstore_test=# select table_name, table_type from information_schema.tables where table_schema='public';
table_name | table_type
-------------------------+------------
customer_reviews | FOREIGN
customer_reviews_cstore | BASE TABLE
dvd | FOREIGN
music | FOREIGN
book | FOREIGN
software | FOREIGN
ce | FOREIGN
toy | FOREIGN
video | FOREIGN
(9 rows)
Time: 0.762 ms
inherit
cstore_test=# SELECT
cstore_test-# nmsp_parent.nspname AS parent_schema,
cstore_test-# parent.relname AS parent,
cstore_test-# nmsp_child.nspname AS child_schema,
cstore_test-# child.relname AS child
cstore_test-# FROM pg_inherits
cstore_test-# JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
cstore_test-# JOIN pg_class child ON pg_inherits.inhrelid = child.oid
cstore_test-# JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
cstore_test-# JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
cstore_test-# WHERE parent.relname='customer_reviews';
parent_schema | parent | child_schema | child
---------------+--------+--------------+-------
(0 rows)
Time: 0.815 ms
cstore_test=# SELECT
nmsp_parent.nspname AS parent_schema,
parent.relname AS parent,
nmsp_child.nspname AS child_schema,
child.relname AS child
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='customer_reviews_cstore';
parent_schema | parent | child_schema | child
---------------+-------------------------+--------------+----------
public | customer_reviews_cstore | public | dvd
public | customer_reviews_cstore | public | music
public | customer_reviews_cstore | public | book
public | customer_reviews_cstore | public | software
public | customer_reviews_cstore | public | ce
public | customer_reviews_cstore | public | toy
public | customer_reviews_cstore | public | video
(7 rows)
Time: 0.764 ms
cstore_test=# select product_group, count(*) from customer_reviews group by product_group;
product_group | count
---------------+---------
DVD | 121418
Video | 142235
Music | 300628
Book | 1198218
Software | 1
CE | 1
Toy | 3
(7 rows)
Time: 258.150 ms
cstore_test=# select product_group, count(*) from customer_reviews_cstore group by product_group;
product_group | count
---------------+---------
Book | 1198218
CE | 1
DVD | 121418
Music | 300628
Software | 1
Toy | 3
Video | 142235
(7 rows)
Time: 264.642 ms
cstore_test=# select product_sales_rank, cnt from (select product_sales_rank, count(*) as cnt from customer_reviews group by product_sales_rank) m order by product_sales_rank limit 10;
product_sales_rank | cnt
--------------------+------1 | 350 | 91 | 262 | 157 | 388 | 512 | 2214 | 316 | 1417 | 75
(10 rows)
Time: 424.297 ms
cstore_test=# select product_sales_rank, cnt from (select product_sales_rank, count(*) as cnt from customer_reviews_cstore group by product_sales_rank) m order by product_sales_rank limit 10;
product_sales_rank | cnt
--------------------+------1 | 350 | 91 | 262 | 157 | 388 | 512 | 2214 | 316 | 1417 | 75
(10 rows)
Query results(product_sales_rank=-1 by each partition)
cstore_test=# select 'book', count(*) from book where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'music', count(*) from music where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'video', count(*) from video where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'toy', count(*) from toy where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'ce', count(*) from ce where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'software', count(*) from software where product_sales_rank=-1
cstore_test-# union all
cstore_test-# select 'dvd', count(*) from dvd where product_sales_rank=-1;
?column? | count
----------+-------
software | 0
ce | 0
toy | 0
dvd | 0
video | 0
music | 6
book | 29
(7 rows)
Time: 109.880 ms