Questions tagged [exists]
The exists tag has no usage guidance.
6
questions
121
votes
5
answers
302k
views
Best practice between using LEFT JOIN or NOT EXISTS
Is there a best practice between using a LEFT JOIN or a NOT EXISTS format?
What is benefit to using one over the other?
If none, which should be preferred?
SELECT *
FROM tableA A
LEFT JOIN tableB B
...
40
votes
2
answers
6k
views
IF EXISTS taking longer than embedded select statement
When I run the following code it takes 22.5 minutes and does 106million reads. However, if I run just the inner select statement by itself it only takes 15 seconds and does 264k reads. As a side note, ...
11
votes
1
answer
4k
views
Does the SQL Spec require a GROUP BY in EXISTS ()
Microsoft currently permits this syntax.
SELECT *
FROM ( VALUES (1) ) AS g(x)
WHERE EXISTS (
SELECT *
FROM ( VALUES (1),(1) )
AS t(x)
WHERE g.x = t.x
HAVING count(*) > 1
);
Notice ...
10
votes
1
answer
28k
views
pg_restore ERROR: "Relation does not exist" and creating new database
I have made a backup of my specific tables that I want to restore into a new database using:
call pg_dump -Fc -h server -d database -U user -p password -v -f dump.sql -t public.table1 -t public....
3
votes
1
answer
2k
views
Full text search on two tsvector columns
I'm trying to do a full text search across two columns of two separate tables in PostgreSQL 9.4.2. The tables and columns are:
article.article_title
keyword.keyword
Where there is a many-to-many ...
0
votes
1
answer
5k
views
How can I create a bool column for a view based on the result of a statement?
I'm using PostgreSQL as my database.
CREATE TABLE groups (
id SERIAL NOT NULL,
name TEXT NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
CREATE TABLE users (
id ...