Re:Implementing faceted search with Django and PostgreSQL
by simonw on Thursday October 05, 2017 @03:05PM
(#15411742)
I think facet counts at scale are probably best handled by Elasticsearch or Solr, but I'd be delighted if a PostgreSQL expert would step in and convince me otherwise based on some of the amazing work that went into PostgreSQL 10.
Calculating the counts for each facet was by far the most expensive part of the query. I found the GROUPING SETS feature very useful to calculate a lot of aggregate counts efficiently. Though this wasn't parallelized by Postgres, I'll have to check if that is possible in Postgres 10 now.
I wondered if there are better ways to calculate facet counts, but I simply can't think of a way that doesn't require at least one full table scan.