Linked Questions
40 questions linked to/from INNER JOIN vs LEFT JOIN performance in SQL Server
0 votes
0 answers
132 views
Is there any performance difference between using inner join vs left join? [duplicate]
I was just writing a query when I thought of this. My query will yield exactly the same result using either inner join or left join, since I'm joining tables on a foreign key relationship, selecting ...
185 votes
10 answers
134k views
Does Foreign Key improve query performance?
Suppose I have 2 tables, Products and ProductCategories. Both tables have relationship on CategoryId. And this is the query. SELECT p.ProductId, p.Name, c.CategoryId, c.Name AS Category FROM Products ...
61 votes
5 answers
16k views
Should I avoid multi-table (concrete) inheritance in Django by any means?
Many experienced developers recommend against using Django multi-table inheritance because of its poor performance: Django gotcha: concrete inheritance by Jacob Kaplan-Moss, a core contributor of ...
25 votes
3 answers
69k views
Query Performance INNER JOIN ON AND comparison
I would like to know which one is best regarding performance between the 2 queries stated below or do they perform identically? First one: [without WHERE clause, just AND with ON] SELECT ...
31 votes
2 answers
46k views
LEFT JOIN Significantly faster than INNER JOIN
I have a table (MainTable) with a bit over 600,000 records. It joins onto itself via a 2nd table (JoinTable) in a parent/child type relationship: SELECT Child.ID, Parent.ID FROM MainTable AS ...
3 votes
3 answers
19k views
inner join vs left join - which is faster for the same result?
If both inner join and left join can achieve the same result, which one is faster and has better performance (especially on large data)? inner join: SELECT * FROM Table_A A INNER JOIN Table_B B ON A....
6 votes
2 answers
42k views
postgresql JOIN with multiple conditions
I have two postgres tables: worker_details_verification (verification_id BIGSERIAL, worker_id BIGINT, state TEXT, proofs TEXT[]) worker_details(worker_id BIGINT, name TEXT) Now I want to get `...
3 votes
2 answers
7k views
Performance difference between left join and inner join
Is there any difference between left join and inner join regarding performance? I use SQL Server 2012.
11 votes
3 answers
9k views
MySQL Inner Join VS Left Join w/ IS NOT NULL?
Is there a performance difference in the following? SELECT person.id FROM person LEFT JOIN address ON person.id = address.personID WHERE address.personID IS NOT NULL vs SELECT person.id FROM person ...
4 votes
3 answers
6k views
Mysql - LEFT JOIN way faster than INNER JOIN
I have two tables Table X: millions or records |-----|-----|-----|-----| | a | b | c | d | |-----|-----|-----|-----| Table Y: only a few records |-----|-----| | e | f | |-----|-----| X....
2 votes
1 answer
6k views
Outer JOIN vs Inner JOIN
I have always thought that Inner Join performs better than Outer JOIN, but I've experienced several cases now where this simply isn't true... The other day I was creating a query with a series of ...
0 votes
1 answer
3k views
Difference of "FROM a LEFT JOIN b" vs. "FROM a, b"
Do the queries do the same? What is the standard? Will I lose performance if I change one of these ways of write the query? Query 1 SELECT a.*, b.id AS b_id FROM table_a AS a LEFT JOIN ...
3 votes
6 answers
697 views
Improving performance of adding a column with a single value
By experimentation and surprisingly, I have found out that LEFT JOINING a point-table is much faster on large tables then a simple assigning of a single value to a column. By a point-table I mean a ...
1 vote
2 answers
1k views
Issue in query with inner join and concat() operation in mysql
I have two tables: sk_accounts //details of user acnt_user_id acnt_fname //first name acnt_lname acnt_profile_picture acnt_member_class so on........ sk_following //table containing ...
1 vote
3 answers
1k views
Fetching records from the MySQL database from 10 tables
I have a database with 20 tables inside it. I want to fetch records from 10 related tables at a time, and I am using Hibernate. What is the best solution: to write a single query using join with ...
0 votes
4 answers
199 views
How can I optimize my SQL query to run faster?
SELECT b.User_Id ,(CONVERT(varchar, DATEADD(hh, - 7, b.callstartdt), 101))as 'Dt' ,(COUNT(distinct b.SeqNum ) + Count(distinct c.SeqNum) + count(distinct d.seqnum)) as 'TotalCalls' ,COUNT(...
0 votes
1 answer
1k views
SQL join to see if a row exists in multiple tables
So I have 3 tables: Users, Purchases A, and Purchases B. I want to find all users that have made any purchase within the first 30 days of joining. So all users with a purchase from either Purchases A ...
-4 votes
1 answer
2k views
NETEZZA: Can LEFT JOIN be faster than INNER JOIN?
Query: SELECT * FROM TABLE1 TBL INNER JOIN CROSS_REF_TABLE XREF ON TBL.COL = XREF.COL VS SELECT * FROM TABLE1 TBL LEFT JOIN CROSS_REF_TABLE XREF ON TBL.COL = XREF.COL WHERE XREF.COL IS NOT NULL Can ...
-2 votes
5 answers
232 views
Ignore repeated rows with SELECT statement
I have a table like below. One table for storing fruits and one for its type. create table fruits(fruit_id int, fruit_name VARCHAR(255)); create table type(fruit_id int, status VARCHAR(255)); ...
1 vote
2 answers
630 views
Simulating inner join with left join
I know you can simulate an inner join using a left join like this: select * from a inner join b on a.Id= b.Id select * from a left join b on 1 = 1 where a.Id= b.Id I'm wondering about this one. ...
1 vote
2 answers
2k views
Is there inner join and outer join performance difference
I read some existing codes and found out all SQLs wrote as outer join even it is inner join. Then, I start to think about the performance difference between if the result are same. In my mind, inner ...
-2 votes
2 answers
1k views
Execution time taken by different SQL JOINS
Below two queries result the same result set. In first I have only used INNER JOIN and in second query mix of joins like LEFT and RIGHT JOIN. I personally prefer INNER JOIN when there is no specific ...
0 votes
1 answer
930 views
how to select COUNT in subquery in optimized way
I have a question about count in subquery in mysql database. Suppose I have a book table that has a author_id and an author table with id and name. I want to get author list with number of books for ...
1 vote
1 answer
1k views
PRESTO Optimising Queries on LEFT JOIN/INNER JOIN
I am running presto query and wondering which will improves the efficiency of the query. For example, I have Table A (Huge amount of rows) and Table B(little amount of rows) If I want to do a LEFT ...
1 vote
1 answer
545 views
Difference between inner join and left join if tables have matching row counts and primary keys
In SQL Server, I'm creating a view that references several tables that should have the same row counts and primary keys, although different column data between them (hence the need to pull them all ...
0 votes
0 answers
537 views
DB::raw in Laravel takes long time
I've a Laravel 5.2 application, I need to make an advanced query to the database so I'm trying to use the DB::raw expression, mainly, my query is like this: SELECT * FROM TableA AS s LEFT ...
1 vote
2 answers
68 views
How to get related questions using tag_ids in MySQL?
I have a MySQL database structure which has questions and tags, something like stackoverflow. So my three tables are like this : questions: ----------------------- id | content | asked_on tags: ----...
1 vote
3 answers
73 views
Select locations from two tables
I am new to SQL and I'm having difficulties writing the following query. Scenario A user has two addresses, home address (App\User) and listing address (App\Listing). When a visitor searches for ...
0 votes
2 answers
126 views
Why LEFT JOIN is terribly slower than INNER JOIN?
I have two tables, toynav_product_import - 18533 rows, catalog_product_entity - 42000 rows. The below query, LEFT JOIN takes more than 2 minutes, while INNER JOIN runs in 0.009 seconds. The first ...
-11 votes
1 answer
143 views
How to improve performance of this query [closed]
select * from dbo.tble select * from dbo.tble
1 vote
2 answers
83 views
How to count and follow foreign keys from a foreign key ID
So basically I have a table called folders, which store data which I use to build up a file structure on a website, now one of the limits I wish to impose is only allowing the user to make 3 folders ...
0 votes
1 answer
93 views
MySQL Query - Object Queuing Based on Object Property to Skill Mapping
Okay, so I know the title is a bit cryptic so I'll do what I can to explain the "problem" I have and the solution I am currently using. Problem: An 'object' of work needs to be distributed to the ...
-1 votes
1 answer
81 views
MSSQL select query optimization
Is there any optimization possible in the select query below? SELECT AwardAction.strActionName, AwardType.strAwardName, Award.strStudentId,Award.iCount FROM [dbo].[Awards] Award,...
0 votes
1 answer
96 views
master table with 11 constant column vs master table with separate constant table
I have a database table (called Master) which has about 40 columns. 11 of them always contains the constant values for about every 100.000 rows. The down side of this structure is that, when I need ...
0 votes
2 answers
77 views
Correct way to query MySQL table with 2m+ rows based on criteria from a separate table
Terrible title, sorry for not being able to concisely articulate this question. I have a MySQL table (Table name: users) with 2m+ users (rows) in it. Each one has a score for that user. (Columns: ...
0 votes
3 answers
89 views
SQL Join with GROUP BY query optimisation
I'm trying to optimise the following query. SELECT C.name, COUNT(DISTINCT I.id), COUNT(B.id) FROM Categories C, Items I, Bids B WHERE C.id = I.category AND I.id = B.item_id GROUP BY C....
1 vote
3 answers
67 views
MYSQL Count and Join Query
Table: User Color 1 2 2 2 1 3 Table: Color ID Name 1 Orange 2 Yellow 3 Pink 4 Blue Expected Result Color Total Orange 2 Yellow 3 Pink 1 Mysql Query: ...
0 votes
1 answer
62 views
Is there a more efficient way to join these tables?
I have a couple of tables in a DB2 database. Table_1 looks like this (the actual table is 9.2 million rows): Customer_ID Offer Item_list A X 1 A Y 2 B Y 2 Table_2 looks like this (the actual table is ...
0 votes
1 answer
54 views
finding efficient way of conditional query for oracle database
I have two tables, called "Orders" and "Holidays" The "Orders" table orderId | orderDate 1 02-03-2017 ...
0 votes
1 answer
33 views
How to get records with column value null including others?
I have the following query In which I have all the selected columns in mResourceAllocation and mResource table with foreign keys. In mResourceAllocation foreign key columns CoreFunction_ID (Function) ...