Skip to content

plotts/median

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Current state

  • Has been tested with 50k rows for integer and bigint; 32k rows for smallint.
  • Integer 2/4/8, float and double work as"regular" medians and in moving aggregate mode
  • Timestamps work, also in moving aggregate mode.
  • VARCHAR and TEXT works for regular medians, not moving aggregate mode.
  • Some additional tests are in place - median2.sql

Given the data type restrictions, above, these SQL examples "work". :)

Vanilla:

SELECT id, temp, median(temp) FROM newtable;

Or a simple windowing function like:

SELECT id, temp, median(temp) OVER (ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) FROM newtable;

What's left...

  • Parallelism. need to learn more about this.
  • Moving aggregates for VARCHAR/TEXT types - this seems like a memory allocation/scoping issue.
  • Has not been tested with huge data sets.
  • Has not been performance tested.

About

PostgreSQL median function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published