select tableA.id from tableA left outer join tableB on (tableA.id = tableB.id)
where tableB.id is null
order by tableA.id desc
If your db knows how to do index intersections, this will only touch the primary key index
More Related Contents:
- SQL Server indexes – ascending or descending, what difference does it make?
- Fastest way to remove non-numeric characters from a VARCHAR in SQL Server
- MySQL not using indexes with WHERE IN clause?
- What are your most common sql optimizations?
- SQL: How to properly check if a record exists
- Is it possible to perform multiple updates with a single UPDATE SQL statement?
- SQL query that gives distinct results that match multiple columns
- How to Optimize Queries in a Database – The Basics
- Measuring Query Performance : “Execution Plan Query Cost” vs “Time Taken”
- How in H2DB get sql dump like in MySql?
- Get the mentioned output by SQL query
- Decrease salary using a SQL query
- Reason for Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause [duplicate]
- ORA-12560: TNS:protocol adaptor error
- Select statement to find duplicates on certain fields
- How to use DISTINCT and ORDER BY in same SELECT statement?
- Getting only Month and Year from SQL DATE
- Does MS SQL Server’s “between” include the range boundaries?
- basic recursive query on sqlite3?
- What is a self join for? (in english)
- Check for file exists or not in sql server?
- How to ORDER BY a SUM() in MySQL?
- How to create a PivotTable in Transact/SQL?
- How to split comma-separated values?
- What is Full Text Search vs LIKE
- SQL – Inserting a row and returning primary key
- How to return default value from SQL query
- Is this a good way to model address information in a relational database?
- Conditional aggregation performance
- Retrieve Oracle last inserted IDENTITY