Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • How many rows in "mytable"? How many different "item_id" values there? Commented Mar 31, 2018 at 3:00
  • Also, shouldn't you have uniqueness constraint (probably not-yet-defined unique index) in on item_id in mytable? ... Edited: oh, I see "PARTITION BY item_id", so this question transforms to "What is the natural, real key for your data? What should form unique index there?" Commented Mar 31, 2018 at 3:03
  • About 12 million rows in mytable, with about 500k different item_id. There is no real natural unique key for this table, it's data that's generated automatically for repeating events. I guess the item_id + start_date + name (field not shown here) could constitute some kind of key. Commented Apr 2, 2018 at 19:22
  • Can you post the execution plan you're getting? Commented Apr 4, 2018 at 8:53
  • Sure, added the explain analyze to the question. Commented Apr 4, 2018 at 18:11