Linked Questions

0 votes
0 answers
132 views

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 ...
Awer Muller's user avatar
185 votes
10 answers
134k views

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 ...
Chaowlert Chaisrichalermpol's user avatar
61 votes
5 answers
16k views

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 ...
utapyngo's user avatar
  • 7,204
25 votes
3 answers
69k views

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 ...
Rashidul Islam's user avatar
31 votes
2 answers
46k views

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 ...
Greg's user avatar
  • 3,532
3 votes
3 answers
19k views

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....
Run's user avatar
  • 57.7k
6 votes
2 answers
42k views

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 `...
Sankar's user avatar
  • 6,591
3 votes
2 answers
7k views

Is there any difference between left join and inner join regarding performance? I use SQL Server 2012.
mehdi lotfi's user avatar
  • 11.6k
11 votes
3 answers
9k views

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 ...
Brian's user avatar
  • 7,195
4 votes
3 answers
6k views

I have two tables Table X: millions or records |-----|-----|-----|-----| | a | b | c | d | |-----|-----|-----|-----| Table Y: only a few records |-----|-----| | e | f | |-----|-----| X....
benjamin.d's user avatar
  • 2,881
2 votes
1 answer
6k views

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 ...
TGH's user avatar
  • 39.4k
0 votes
1 answer
3k views

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 ...
Gabriel Santos's user avatar
3 votes
6 answers
697 views

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 ...
Przemyslaw Remin's user avatar
1 vote
2 answers
1k views

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 ...
Techy's user avatar
  • 2,654
1 vote
3 answers
1k views

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 ...
subodh's user avatar
  • 6,158
0 votes
4 answers
199 views

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(...
lookslikeanevo's user avatar
0 votes
1 answer
1k views

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 ...
country_dev's user avatar
-4 votes
1 answer
2k views

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 ...
an125's user avatar
  • 31
-2 votes
5 answers
232 views

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)); ...
user1093513's user avatar
1 vote
2 answers
630 views

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. ...
j doe's user avatar
  • 51
1 vote
2 answers
2k views

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 ...
Hongtao's user avatar
  • 195
-2 votes
2 answers
1k views

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 ...
Aamir Mohiuddin's user avatar
0 votes
1 answer
930 views

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 ...
hamed's user avatar
  • 8,045
1 vote
1 answer
1k views

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 ...
Shlim's user avatar
  • 47
1 vote
1 answer
545 views

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 ...
Ian Joyce's user avatar
  • 1,069
0 votes
0 answers
537 views

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 ...
Sredny M Casanova's user avatar
1 vote
2 answers
68 views

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: ----...
jeff's user avatar
  • 13.8k
1 vote
3 answers
73 views

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 ...
Kim Kyo's user avatar
  • 75
0 votes
2 answers
126 views

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 ...
Duke's user avatar
  • 37.3k
-11 votes
1 answer
143 views

select * from dbo.tble select * from dbo.tble
Alexo's user avatar
  • 19
1 vote
2 answers
83 views

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 ...
Erdss4's user avatar
  • 1,155
0 votes
1 answer
93 views

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 ...
kdougan's user avatar
  • 343
-1 votes
1 answer
81 views

Is there any optimization possible in the select query below? SELECT AwardAction.strActionName, AwardType.strAwardName, Award.strStudentId,Award.iCount FROM [dbo].[Awards] Award,...
Vignesh Subramanian's user avatar
0 votes
1 answer
96 views

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 ...
Iwalu's user avatar
  • 5
0 votes
2 answers
77 views

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: ...
freefishfoundry's user avatar
0 votes
3 answers
89 views

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....
William Wu's user avatar
1 vote
3 answers
67 views

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: ...
Shah Rushabh's user avatar
0 votes
1 answer
62 views

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 ...
SRJCoding's user avatar
  • 521
0 votes
1 answer
54 views

I have two tables, called "Orders" and "Holidays" The "Orders" table orderId |   orderDate      1         02-03-2017 ...
Michael's user avatar
  • 63
0 votes
1 answer
33 views

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) ...
Renascent's user avatar
  • 184