Commit Graph

4 Commits

Author SHA1 Message Date
evazion
a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00
evazion
ed302fdf4d docs: add documentation for various classes in app/logical. 2021-06-23 06:23:29 -05:00
evazion
93f6e935a8 search: fix underestimation of page count for blank searches.
Bug: In Postgres 13, getting the count of a blank search underestimated
the page count by a large margin (~700,000 posts).

The query we were executing was this:

    EXPLAIN (FORMAT JSON) SELECT * FROM posts ORDER BY id DESC

The `ORDER BY id DESC` clause triggered a parallel seq scan query plan
in Postgres 13, which for some reason causes Postgres to underestimate
the row count by large amount in each parallel branch.

Getting rid of the ORDER BY clause makes it do a regular seq scan, which
gives an accurate estimate.
2021-02-18 04:37:27 -06:00
evazion
41c6c882c2 search: refactor fast_count to return nil on timeout.
* Refactor fast_count to return nil instead of 1,000,000 if the exact count times out.
* Remove the estimate_post_counts and blank_tag_search_fast_count global config options.
* Replace the hardcoded post count estimates inside fast_count with a
  method that parses Postgres's estimated row count from EXPLAIN.

* /counts/posts.json:
** Remove the `raise_on_timeout` parameter.
** Add an `estimate_count=<true|false>` parameter.
** Return null instead of 1,000,000 if the exact count times out.
2020-05-07 21:02:22 -05:00