You can select "for update", so you ensure that the rows are locked for
your current transaction's use exclusively. If the rows in question had
been modified by another ongoing transaction, then the select will get
blocked until the other transaction is finished.
Cheers,
Ezequie
.add_date
HAVING uu.user_id=1
ORDER BY uu.add_date::date DESC
LIMIT 7
) x;
Perhaps a select distinct instead of the group by in the subquery would
make use the index?
Cheers,
Ezequiel Tolnay
---(end of broadcast)---
TIP 2: you can get off all lis
ou to iterate over the results by doing the following:
_t := 0;
FOR _myrecord IN SELECT * FROM myfunction(...)
LOOP
_t := _t + _myrecord.mycolumn;
END LOOP;
Cheers,
Ezequiel Tolnay
---(end of broadcast)---
TIP 8: explain analyze is your friend
value column is the data
that I am interested in:
SELECT t.id, t.value
FROM (SELECT name, MAX(numb) as numb FROM test1) AS s
JOIN test1 t ON (t.name = s.name AND t.numb = s.numb);
id value
-- -
6 6000
4 4000
1 1000
Cheers,
Ezequiel Tolnay
[EMAIL PROTECTED]
---(
IN) for larger sets. e.g.:
SELECT rid.dokumnr
FROM rid
LEFT JOIN dok ON (dok.dokumnr = rid.dokumnr)
WHERE dok.dokumnr iS NULL;
Cheers,
Ezequiel Tolnay
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]