Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 61

A database structure that can improve the speed of queries at the cost of disk space and slower inserts/updates. It stores a copy of one or more columns sorted but structures the data differently to allow faster access.

2 votes

Postgres indexes for 75 columns

If laurenz's suggestion of enforcing limitations is not possible for your product, because users will kick back or other stake-holders within the client (as you are not likely talking directly to the …
David Spillett's user avatar
1 vote

Why would deleting a redundant index cause an application to perform unexpectedly?

Would creating an nonclustered index with the same column(s) as the clustered index be the most efficient? … What does the optimizer do in this case - does it still make a plan to include these "bad" indexes that just reference the clustered index, or will it know to ignore the with(index) request? …
David Spillett's user avatar
0 votes

Skip (or speedup) postgres unique index creation if I know beforehand that it's unique

Is there a way to tell postgres to skip that index validation, because "I swear to god, it's unique" There would be no point, because without properly creasing three index next time you insert or update … Similarly when changing data in a table with a foreign key referring that index. This would have to happen for every relevant data change. …
David Spillett's user avatar
1 vote
Accepted

MySQL add key to a table that is in use

IIRC mysql has supported online secondary index creation for some time, assuming you are using a decent table type like InnoDB: https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html … “the table remains available for read and write operations while the index is being created”. …
David Spillett's user avatar
1 vote

Advantage of using INCLUDE as against adding the column in INDEX for covering index

The INCLUDEd columns do not have to be kept in a stable order so if you update those columns (without changing their size if variable, or updating the others covered by the index) things do not need to … Just what it says: the value is copied into the index so the index is larger, and if there is an index scan or partial scan more pages will probably need to be accessed. …
David Spillett's user avatar
-1 votes

Does adding a non clustered index to foreign key speed up the join?

With an index on Sales.UID it will likely scan users and be able to join using sales more efficiently because the joining field is pre-sorted by the index. … If you are likely to search by date rather than listing all sales, then an index with Sales.Date as the first covered column might be more helpful. …
David Spillett's user avatar
1 vote
Accepted

Possible to create a constraint that is unique per foreign key?

Unique constrains, like any other index, can convert multiple columns in the same table - so to achieve what I think you are asking for you need to create a unique constraint on userId, repoId. … See When should I use a unique constraint instead of a unique index? for more discussion about that similarity and when you might choose one over the other. …
David Spillett's user avatar
0 votes

Execution plan changed for existing query - high CPU usage

expense of a little disk space & memory due to the larger index. … In other DBs (MS SQL Server, Prosgres, ...) you can reduce the space hit by removing any index you have on just company_id and the compound index will be used instead (assuming company_id is the first …
David Spillett's user avatar
1 vote
Accepted

Truncate and insert: Heap and build index or directly into Clustered table

If you turn the index off so that you have a heap, when you readd the clustered index it will have to reread the data, perform the same sort, and rewrite the pages in the new order - so it will be as expensive … , probably more so, than the initial insert with the clustered index turned on. …
David Spillett's user avatar
4 votes

SQLServer - treat table as index

So in this example if you later add an index on only value you effectively have an index containing everything again (i.e. your original concern). … Off the top of my head I'm not sure if this would behave as an index on value including location, device, timestamp, type or an index on value, location, device, timestamp, type. …
David Spillett's user avatar
1 vote

Clustered index in ETL (drop - insert - create?)

If the inserts are roughly in clustered index order, or are a bulk inserted (so can be ordered by the engine) then keeping the clustered index but dropping any non-clustered indexes and recreating them … If you are caring about time and not space (so the internal fragmentation due to extra page splits is not a big issue) then even with arbitrarily ordered individual inserts keeping the clustered index
David Spillett's user avatar
2 votes

Postgres: Performance: Slow index scan

Looking at the query: most of your LEFT JOINs are not really LEFT JOINs because of the predicate ON TRUE which makes them behave as CROSS JOINs. Your query is considering every row that comes out of: …
David Spillett's user avatar
1 vote

How to speed up counting and filtering on table with a lot of columns and filter conditions?

That removes the quick solution of "index the most commonly touched columns, and let the rest still scan" so the only other quick solution is an index on each of the columns. … The query planner will hopefully pick the most selective index option each time reducing the number of rows than need everything else to be checked. …
David Spillett's user avatar
2 votes

Using an index when leading column is not in the predicate

Further note that in every circumstance where a skip-scan is better than a full index scan, having an index on the second column to use would be more efficient, often significantly so, meaning that while … it uses some other NC index To explain why that particular index is selected and used instead of any other, we would need to know how that index and all the other indexes are defined, and perhaps see …
David Spillett's user avatar
1 vote

Best way to solve a lot of queries stuck because of no index

index is the only solution. … Perhaps go for an online index build if possible - that will take longer but won't completely block part of the application while it does the job. …
David Spillett's user avatar

15 30 50 per page