Re: Why isn't an index scan being used?

2019-02-19 Thread Abi Noda
Thanks Justin. The 4ms different in the examples isn't an accurate benchmark. I'm seeing about a ~20% difference over a larger sample size. And this is on a fork of the production database. Apart from the end-performance, I'm motivated to figure out why one index results in an index scan whereas

Re: Why isn't an index scan being used?

2019-02-19 Thread Justin Pryzby
On Tue, Feb 19, 2019 at 05:10:43PM -0700, Abi Noda wrote: > I have a table as defined below. The table contains 1,027,616 rows, 50,349 > of which have state='open' and closed IS NULL. Since closed IS NULL for all > rows where state='open', I want to remove the unnecessary state column. > > CREATE

Re: Why isn't an index scan being used?

2019-02-19 Thread Michael Lewis
On Tue, Feb 19, 2019, 8:00 PM Andrew Gierth > "Abi" == Abi Noda writes: > > Abi> However, when I index the closed column, a bitmap scan is used > Abi> instead of an index scan, with slightly slower performance. Why > Abi> isn't an index scan being used, given that the exact same number >

Re: Why isn't an index scan being used?

2019-02-19 Thread Andrew Gierth
> "Abi" == Abi Noda writes: Abi> However, when I index the closed column, a bitmap scan is used Abi> instead of an index scan, with slightly slower performance. Why Abi> isn't an index scan being used, given that the exact same number Abi> of rows are at play as in my query on the state c

Re: Why isn't an index scan being used?

2019-02-19 Thread Abi Noda
Thank you for the help. > If the "closed_index" index is large than the "state_index", then doing an Index scan on "closed_index" is going to be costed higher. FWIW, both indexes appear to be the same size: select pg_size_pretty(pg_relation_size('state_index')); 1144 kB select pg_size_pretty(pg

Re: Why isn't an index scan being used?

2019-02-19 Thread David Rowley
On Wed, 20 Feb 2019 at 13:11, Abi Noda wrote: > However, when I index the closed column, a bitmap scan is used instead of an > index scan, with slightly slower performance. Why isn't an index scan being > used, given that the exact same number of rows are at play as in my query on > the state c

Why isn't an index scan being used?

2019-02-19 Thread Abi Noda
*Postgres version: PostgreSQL 10.3 on x86_64-apple-darwin16.7.0* *Operating system and version: MacOS v10.12.6* *How you installed PostgreSQL: Homebrew* I have a table as defined below. The table contains 1,027,616 rows, 50,349 of which have state='open' and closed IS NULL. Since closed IS NULL fo

Re: index on jsonb col with 2D array inside the json

2019-02-19 Thread Mariel Cherkassky
Thanks for the feedback! On Tue, Feb 19, 2019, 6:42 PM Michael Lewis I would expect that R2 vs R3 would be negligible but perhaps gist works > much better and would be an improvement. When you are down to 7ms already, > I wouldn't hope for any big change. I assume you used btree for the > multi-c

Re: index on jsonb col with 2D array inside the json

2019-02-19 Thread Michael Lewis
I would expect that R2 vs R3 would be negligible but perhaps gist works much better and would be an improvement. When you are down to 7ms already, I wouldn't hope for any big change. I assume you used btree for the multi-column index on R2 range_first, range_last but am not familiar with gist on ra

Re: index on jsonb col with 2D array inside the json

2019-02-19 Thread Mariel Cherkassky
I dont have any indexes on R (the table with the jsonb column). I was asking if I can create any that can increase this query`s performance. If I understood you correctly I have 3 options right now : 1)R, without indexes 2)R2 with an index on first and last 3)R3 that should contain a single range

Re: index on jsonb col with 2D array inside the json

2019-02-19 Thread Michael Lewis
Is your JSON data getting toasted? I wouldn't assume so if it is remaining small but something to check. Regardless, if an index exists and isn't being used, then that would be the primary concern. You didn't share what the definition of the index on R.data is... what do you already have? You have

index on jsonb col with 2D array inside the json

2019-02-19 Thread Mariel Cherkassky
Hi, I have a table with json col : R(object int, data jsonb). Example for content : object | data +--- 50 | {"ranges": [[1, 1]]} 51 | {"ranges": [[5, 700],[1,5],[9,10} 52 | {"ranges":

Re: Performance regressions found using sqlfuzz

2019-02-19 Thread Jung, Jinho
Andres, Andrew, and Tom: Thanks for your insightful comments! We conducted additional analysis based on your comments and would like to share the results. We would also like to get your feedback on a few design decisions to increase the utility of our performance regression reports. ###