/srv/irclogs.ubuntu.com/2013/07/16/#launchpad-dev.txt

StevenKwgrant: http://pastebin.ubuntu.com/5879216/ without the ORDER BY. It's very strange.00:02
wgrantStevenK: How's it strange?00:02
StevenKI guess I'm used to postgres returning unordered data with no ORDER BY, this is always ordered00:03
wgrantIt's not ordered or unordered00:04
wgrantIt's ordered by however it happens to come out00:04
wgrantSo, I would use a subselect to be simple and sure00:07
StevenKwgrant: So SELECT * FROM (blah..) ORDER BY ... ?00:16
wgrantStevenK: Other way around00:17
wgrantYou need to do the sort on the inside, group on the outside00:17
wgrantYou don't care about the order of the groups00:17
wgrantYou care about the selection of the group result rows00:17
StevenKwgrant: http://pastebin.ubuntu.com/5879285/00:37
wgrantStevenK: That looks substantially more sensible and likely to work01:38
StevenKwgrant: But they're both the same!01:52
wgrant... indeed01:53
wgrantI guess it's not at all surprising :)01:54
wgrantGROUP BY with extra columns isn't meant to be permitted01:55
wgrantSince it doesn't have an obvious meaning01:55
wgrantStevenK: Rework to use a subquery with GROUP BY and MAX(date), then join the extra columns in the outer query?01:55
wgrantThat has to work01:55
wgrantProbably slow, but we have a proper solution for prod01:56
StevenKwgrant: SELECTing what, though?03:16
StevenKI need to pull out at least one extra column, 'id'03:16
wgrantStevenK: Why?03:25
wgrantStevenK: Select the GROUP BY cols and MAX(date)03:25
wgrantThen join in the outer query, filtering by the GROUP BY cols and date03:25
=== tasdomas_afk is now known as tasdomas
StevenKwgrant: http://pastebin.ubuntu.com/5879591/03:31
wgrantdat caps03:32
wgrantWhy left join?03:32
wgrantAnd that join is the wrong way around03:32
StevenKwgrant: I was guessing03:32
wgrantAnd it'll return duplicates... possibly best to do a second group by on the outer layer, I guess03:32
wgrantNever guess :)03:32
wgrantThis is SQL03:33
wgrantNot some other thing that you might have to guess about :)03:33
wgrantLEFT JOIN has a very specific purpoise03:33
StevenKYeah03:33
StevenKIt looks right with JOIN03:33
wgrantI'd hope so03:35
wgrantGiven that it's what you want!03:35
StevenKwgrant: http://pastebin.ubuntu.com/5879605/03:37
wgrantStevenK: I'd add a further GROUP BY on the outside to eliminate dupes with the same key and date03:40
StevenKwgrant: http://pastebin.ubuntu.com/5879610/03:42
StevenKwgrant: You're happy with that query and I should continue trying to get Django to actually use it?06:04
=== tasdomas is now known as tasdomas_afk
wgrantStevenK: That sounds reasonable06:04
StevenKWhich might involve swearing, throwing screwdrivers at the wall, and if I get really desperate -- gin06:05
wgrantOr ""06:06
StevenKNot quite that simple, since I'd like to deal with the case where only one of object or operation were specified06:06
=== tasdomas_afk is now known as tasdomas
=== tasdomas is now known as tasdomas_afk
=== tasdomas_afk is now known as tasdomas
=== tasdomas is now known as tasdomas_afk
=== Ursinha_ is now known as Ursinha
=== tasdomas_afk is now known as tasdomas
=== tasdomas is now known as tasdomas_afk
=== matsubara is now known as matsubara-lunch
=== matsubara-lunch is now known as matsubara
=== tasdomas_afk is now known as tasdomas
=== tasdomas is now known as tasdomas_afk
=== maxb_ is now known as maxb

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!