3 ms·
I have encountered situations where this is convenient, and I have yet to see it cause any bugs or problems. In the places I have seen it used, the 'arbitrary'
by tveita 14y ago
I have encountered situations where this is convenient, and I have yet to see it cause any bugs or problems.
In the places I have seen it used, the 'arbitrary' column typically has the same value for the entire group, e.g. for efficiently selecting distinct texts based on their hash values.
PostgreSQL has a similar feature using SELECT DISTINCT ON:
http://www.postgresql.org/docs/9.2/static/queries-select-lists.html http://www.postgresql.org/docs/9.2/static/queries-select-lis...
- zzzeek 14y ago> In the places I have seen it used, the 'arbitrary' column typically has the same value for the entire group, e.g. for efficiently selecting distinct texts based on their hash values. I agree that case is convenient. But I've seen it being used to actually pick a random row, where a different row would have a different result (such that the output of the program would definitely be different), and it's clear the developers who wrote it didn't fully understand this was going on. I wrote it up in a report for this particular client but they didn't seem to want to touch this particular very old and venerable code.
- jeltz 14y agoI have seen bugs caused by this and I have only worked a little with MySQL. I agree though that the behaviour is very convenient, but the PostgreSQL way of implementing it is superior since it is more explicit about what it does and it also can be combined with ORDER BY so it does not just give you a random row.