Skip to content
Advertisement

Tag: sqlperformance

Is it better to pivot data in SQL or in my application code?

I have a very long & narrow table in a MSSQL Database, one that looks a bit like: date dataItemName dataItemValue 2021-01-01 Units Sold 20 2021-01-01 # Customers 2948 2021-01-01 ARP 19 2021-01-02 Units Sold 146 2021-01-02 # Customers 157 2021-01-02 ARP 32 And I’m trying to get a table of the form: date Units Sold # Customers ARP 2021-01-01

Sql Performance join Vs co-related Subquery

TABLE : employee (id,mid,join_date) Question – Find all employees who joined before their managers Query 1: Query 2: Which of them is correct? If both correct, then how is the performance? Answer They are both correct. Performance questions need to be tested on your data on your system. However, with a primary key on employee(id), I would expect both to

Optimizing MySQL-Query for removing duplicates and adjusting foreign key references

i have following tables:address_table and customer_address_table The address table stores addresses and the customer_address table stores the relation between customer and address. A customer can have multiple addresses, therefore the second table. In the address table there are duplicate rows (different id but same location) and there is an address_id reference for each address in the customer_address table, so each

Why to use Correlated Subqueries?

As far as I’ve seen, correlated subqueries can be re-written using multiple-column subqueries or joins. And they usually perform better than correlated subqueries. So in which possible scenarios a correlated subquery can be a better option or the only option? (I use Oracle Database) Answer Oracle has a good optimizer, but correlated subqueries are sometimes the most efficient way to

Advertisement