Re: [SQL] getting duplicate number is there a

2005-05-17 Thread Ezequiel Tolnay
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

Re: [SQL] Trimming the cost of ORDER BY in a simple query

2005-05-06 Thread Ezequiel Tolnay
.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

Re: [SQL] Calling a stored procedure from another stored procedure...

2005-05-06 Thread Ezequiel Tolnay
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

Re: [SQL] SQL group select question

2005-04-18 Thread Ezequiel Tolnay
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] ---(

Re: [SQL] Query runs very slowly in Postgres, but very fast in other DBMS

2005-04-12 Thread Ezequiel Tolnay
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]