Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching for "missing_image" results in time out #581

Closed
ToksT opened this issue Feb 23, 2013 · 4 comments
Closed

Searching for "missing_image" results in time out #581

ToksT opened this issue Feb 23, 2013 · 4 comments

Comments

@ToksT
Copy link
Contributor

ToksT commented Feb 23, 2013

http://danbooru.donmai.us/posts?tags=missing_image
Gives "The database timed out running your query. Try a simpler query that returns fewer results."

@r888888888
Copy link
Collaborator

seems to work now

@Lightforger
Copy link
Contributor

both missing_image and banned_artist time out for me.

@Lightforger Lightforger reopened this Apr 1, 2013
@ToksT
Copy link
Contributor Author

ToksT commented Apr 1, 2013

It takes about 4 seconds to complete for me. That's pretty slow for a single tag search.

@ToksT
Copy link
Contributor Author

ToksT commented Apr 23, 2013

See #1421

@ToksT ToksT closed this as completed Apr 23, 2013
evazion added a commit that referenced this issue Oct 12, 2021
Try to optimize certain types of common slow searches:

* Searches for mutually-exclusive tags (e.g. `1girl multiple_girls`,
  `touhou solo -1girl -1boy`)
* Relatively large tags that are heavily skewed towards old posts
  (e.g. lucky_star, haruhi_suzumiya_no_yuuutsu, inazuma_eleven_(series),
  imageboard_desourced).
* Mid-sized tags in the <30k post range that Postgres thinks are
  big enough for a post id index scan, but a tag index scan is faster.

The general pattern is Postgres not using the tag index because it
thinks scanning down the post id index would be faster, but it's
actually much slower because it degrades to a full table scan. This
usually happens when Postgres thinks a tag is larger or more common than
it really is. Here we try to force Postgres into using the tag index
when we know the search is small.

One case that is still slow is `2girls -multiple_girls`. This returns no
results, but we can't know that without searching all of `2girls`. The
general case is searching for `A -B` where A is a subset of B and A and B
are both large tags.

Hopefully fixes #581, #654, #743, #1020, #1039, #1421, #2207, #4070,
 #4337, #4896, and various other issues raised over the years regarding
slow searches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants