Hi,
In some code I am taking over, I found this query:
select count(t.trame_id) as count, v.voiture_num as voitureNum from
arch_trames t left join voiture v on (v.tag_id=t.tag_id)
where
(t.recept_time = 1243509320691)
and exists (select v2.voiture_num from voiture v2 where v2.tag_id=v.tag_id)
Raphael Bauduin rbli...@gmail.com writes:
select count(t.trame_id) as count, v.voiture_num as voitureNum from
arch_trames t left join voiture v on (v.tag_id=t.tag_id)
where
(t.recept_time = 1243509320691)
and exists (select v2.voiture_num from voiture v2 where v2.tag_id=v.tag_id)
group by
Denis Woodbury wrote:
Hi,
I would like to know if this this type of statement can be used in
Postgresql
IF NOT EXISTS (SELECT 1 FROM Table WHERE col1 = 'mystring' )
BEGIN
...
END
PostgreSQL doesn't have any sort of free block flow control; it doesn't
have an IF statement or similar in SQL.
On Saturday 11. October 2008, Denis Woodbury wrote:
Hi,
I would like to know if this this type of statement can be used in
Postgresql
IF NOT EXISTS (SELECT 1 FROM Table WHERE col1 = 'mystring' )
BEGIN
...
END
If it can, any idea why I get this error.
** Error **
ERROR: syntax
Hello!
I vaguely remember that someone said somewhere that
EXISTS runs faster than IN:
SELECT * FROM table1 where field1 EXISTS (SELECT
field4 FROM table2)
However, all I got from version 7.1.3 is:
ERROR: parser: parse error at or near exists
While below works:
SELECT * FROM table1 where
Hello!
I vaguely remember that someone said somewhere that
EXISTS runs faster than IN:
SELECT * FROM table1 where field1 EXISTS (SELECT
field4 FROM table2)
Move field1 into the subquery and join it to table2. See the FAQ for an
example.
--
Bruce Momjian|
Thank you, I was missing the parens.
If I do an explain I see:
- Index Scan using m_u_and_p_key on m (cost=0.00..3035.22 rows=1363 width=12)
even if I put a limit 1 on the select. Why is that?
Stephan Szabo wrote:
On Mon, 20 Aug 2001, Joseph Shraibman wrote:
I want to select a
Stephan Szabo wrote:
Limit (cost=48.39..48.39 rows=1 width=70)
- Sort (cost=48.39..48.39 rows=2 width=70)
- Hash Join (cost=18.46..48.38 rows=2 width=70)
- Index Scan using u_p_key on u (cost=0.00..27.66 rows=48 width=28)
- Hash
Stephan Szabo wrote:
On Tue, 21 Aug 2001, Joseph Shraibman wrote:
Thank you, I was missing the parens.
If I do an explain I see:
- Index Scan using m_u_and_p_key on m (cost=0.00..3035.22 rows=1363 width=12)
even if I put a limit 1 on the select. Why is that?
Is
Joseph Shraibman [EMAIL PROTECTED] writes:
Well the total cost should be at least as big as the sub-costs, no?
Not if the sub-plan in question is for an EXISTS. The sub-plan cost
is stated in terms of cost to retrieve all rows --- but the outer level
EXISTS isn't going to retrieve all rows,
Joseph Shraibman [EMAIL PROTECTED] writes:
Then why does the explain say rows=1363 ?
That's the estimate of how many rows the inner SELECT would return, if
left free to return them all. You should get the same row count
estimate (though quite possibly a different plan) if you just do
an
Why does explain show more than one row, even if there is a LIMIT = 1?
--
Joseph Shraibman
[EMAIL PROTECTED]
Increase signal to noise ratio. http://www.targabot.com
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to
Joseph Shraibman [EMAIL PROTECTED] writes:
Why does explain show more than one row, even if there is a LIMIT = 1?
What version are you running? I get results like
regression=# explain select * from tenk1 limit 1;
NOTICE: QUERY PLAN:
Limit (cost=0.00..0.03 rows=1 width=148)
- Seq Scan on
I'm running 7.1.3. What does 'rows=1' mean? The number of rows returned or the
number postgres has to look through?
Tom Lane wrote:
Joseph Shraibman [EMAIL PROTECTED] writes:
Why does explain show more than one row, even if there is a LIMIT = 1?
What version are you running? I
I want to select a boolean if there exists a row in another table that matches this
one.
So I did select ..., (select count(*) from table2 where ...) 0 ...
but that count(*) was taking forever. I know there is a better way to do it, but
whenever
I try to use EXISTS I get a syntax error.
On Mon, 20 Aug 2001, Joseph Shraibman wrote:
I want to select a boolean if there exists a row in another table that matches this
one.
So I did select ..., (select count(*) from table2 where ...) 0 ...
but that count(*) was taking forever. I know there is a better way to do it, but
16 matches
Mail list logo