"Alexandre Leclerc" <[EMAIL PROTECTED]> writes: > We have a column (varchar) that has plain text time and it is indexed. > When I do a query with the index, all the data is in the right order, > but when I user ORDER BY .. DESC, the order is messed up. Example:
> By index 1: (date, time, data) > SELECT * from t1; What makes you think that query is using an index? It's probably just returning the data in physical order, which might look correctly ordered if you inserted all the data in time order to start with. > SELECT * from t1 ORDER BY date, time DESC; Perhaps you mean "ORDER BY date DESC, time DESC" ? I don't actually see how a varchar field set up like that would sort in a sensible numeric order at all --- text comparisons are unlikely to do what you'd like with the optional leading one. Consider replacing the varchar with a field of type TIME. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend