MADlib
1.0 A newer version is available
User Documentation
|
For an implementation of quantile using sketches, check out the cmsketch_centile() aggregate in the CountMin (Cormode-Muthukrishnan) module.
quantile
is best used for small tables (e.g. less than 5000 rows, with 1-2 columns in total). For larger tables, consider using quantile_big
instead.SELECT * FROM quantile( 'table_name', 'col_name', quantile);
SELECT * FROM quantile_big( 'table_name', 'col_name', quantile);
sql> CREATE TABLE tab1 AS SELECT generate_series( 1,1000) as col1;
sql> SELECT quantile( 'tab1', 'col1', .3); quantile -------------- 301.48046875 (1 row)