Top "Query-optimization" questions

For questions about making database queries run faster.

Spark SQL: how to cache sql query result without using rdd.cache()

Is there any way to cache a cache sql query result without using rdd.cache()? for examples: output = sqlContext.sql("…

caching query-optimization apache-spark
Can I optimize a SELECT DISTINCT x FROM hugeTable query by creating an index on column x?

I have a huge table, having a much smaller number (by orders of magnitude) of distinct values on some column …

sql sql-server-2005 tsql indexing query-optimization
CPU Time or Elapsed Time - Which actually means SQL Query's Performance?

I have a SQL server 2012 table with 2697 Records and the table is not indexed. The data will get increased in …

sql-server performance query-optimization
MySQL EXPLAIN UPDATE

I am trying to answer the following question as part of my college revision: Create an index on at least …

mysql sql database query-optimization
Which provides better performance one big join or multiple queries?

i have a table called orders. one column on order is customer_id i have a table called customers with 10 …

sql database database-design query-optimization
What is the difference between Seq Scan and Bitmap heap scan in postgres?

In output of explain command I found two terms 'Seq Scan' and 'Bitmap heap Scan'. Can somebody tell me what …

optimization postgresql query-optimization sql-execution-plan
Extremely slow PostgreSQL query with ORDER and LIMIT clauses

I have a table, let's call it "foos", with almost 6 million records in it. I am running the following query: …

sql postgresql query-optimization sql-order-by limit
How to compare two queries?

How can I compare two queries X and Y and say that X is better than Y, when they both …

sql-server query-optimization
Optimizing MySQL LIKE '%string%' queries in innoDB

Having this table: CREATE TABLE `example` ( `id` int(11) unsigned NOT NULL auto_increment, `keywords` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) …

mysql sql indexing query-optimization
Why does direction of index matter in MongoDB?

To quote the docs: When creating an index, the number associated with a key specifies the direction of the index, …

mongodb performance sorting indexing query-optimization