rackerlabs / atom-hopper

ATOM Hopper - The Java ATOMpub Server
http://atomhopper.org
59 stars 55 forks source link

Performance of category search with JDBC Adapter on Postgres #299

Open tvsignal opened 7 years ago

tvsignal commented 7 years ago

Hi, and thanks for this nice feed provider :)

When we have around 25 million entries in the feed, with Atom Hopper 1.2.33 and categories stored in a Postgres array, a search for entries with a given category value is prohibitively slow. When we get a page of entries, we also get the link to an older page. Finding the marker entry id for that link is what slows down everything. We find that atom hopper uses the SQL below.

We have also seen that categories can be stored in a dedicated column when a prefix column map is used, such that posting with the category customer:12312 would put 12312 in the column customer_id. That seems to be working well. However, I wonder why that option isn't properly documented. Are there great downsides to it, or better options? We don't want to rewrite Atom Hopper's SQL...

(SELECT FROM entries WHERE feed = 'comp/dummyfeed' AND datelastupdated = '2017-05-16 11:22:16.710796' AND categories @> '{cat432542}'::varchar[] AND id < 14729912) UNION ALL (SELECT FROM entries WHERE feed = 'comp/dummyfeed' AND datelastupdated < '2017-05-16 11:22:16.710796' AND categories @> '{cat432542}'::varchar[] ORDER BY datelastupdated DESC, id DESC limit 1) ORDER BY datelastupdated DESC, id DESC limit 1

tvsignal commented 7 years ago

No comments? I'm gonna assume that "dedicated column" and "prefix column map" is a good solution, then...