Skip to content

Instantly share code, notes, and snippets.

@toreriklinnerud
Last active June 14, 2023 14:11
Show Gist options
  • Save toreriklinnerud/0f8d96f5bb3f85e84b95fd6c384d72b1 to your computer and use it in GitHub Desktop.
Save toreriklinnerud/0f8d96f5bb3f85e84b95fd6c384d72b1 to your computer and use it in GitHub Desktop.
1. Grab the DB dump
curl -L "https://www.dropbox.com/s/k1ai0765gc2k98f/bug5.sql?dl=1" -o bug5.sql
2. Create an empty database and restore the dump and wait a bit:
createdb bug5 && psql -d bug5 -f bug5.sql && psql -d bug5 -c "ANALYZE"
3. Run queries:
psql -d bug5 -c "set enable_indexscan = 'off'; SELECT a.id FROM a JOIN b ON b.a_id = a.id JOIN c ON c.id = b.c_id WHERE c.tag = '13880'"
1 row expected, get 1
psql -d bug5 -c "set enable_indexscan = 'on'; SELECT a.id FROM a JOIN b ON b.a_id = a.id JOIN c ON c.id = b.c_id WHERE c.tag = '13880'"
1 row expected, get 0
If it doesn't reproduce, drop the DB and try again
dropdb bug5
@toreriklinnerud
Copy link
Author

Screenshot 2023-06-14 at 9 28 40 AM

@tadast
Copy link

tadast commented Jun 14, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment