Sometimes when working with SQL Server, we need to get a quick list of indexes on a given table.
Here are three queries that return all indexes on a given table in SQL Server.
Continue readingSometimes when working with SQL Server, we need to get a quick list of indexes on a given table.
Here are three queries that return all indexes on a given table in SQL Server.
Continue readingIf you’ve gone through the steps for changing the default fill factor in SQL Server, but it doesn’t seem to be taking effect on newly created indexes, it could be because you’ve missed one or two crucial steps.
This issue can also be seen by comparing the value
and value_in_use
columns when querying the sys.configuration
view or using sp_configure
to view the current setting.
The \di
command can be used to list indexes in the current database when using psql
(PostgreSQL’s command-line tool). This meta-command can display all indexes, or just indexes that match certain patterns. Here’s an in-depth explanation of how \di
works, its options, and examples of its various uses.
Below is a query that we can use to quickly identify unused indexes in SQL Server. More specifically, it returns indexes that are updated, but not used.
Continue readingPrimary keys are fundamental to relational database design, ensuring each row in a table can be uniquely identified. They help to maintain data integrity in our databases.
There are many ways to find the primary key column in SQL Server, but sometimes we might need to identify the name of the primary key constraint itself.
Below are three examples of how we can do this.
Continue readingIn PostgreSQL, a partial index is an index that’s built on a subset of the rows in a table. It includes only the rows that satisfy a given condition specified with the WHERE
clause.
Partial indexes can help us achieve faster queries, reduced storage, and lower overhead for write-heavy workloads.
Below is a quick example that demonstrates how to create a partial index in PostgreSQL.
Continue readingThe INCLUDE
option in SQL Server allows us to include non-key columns in a nonclustered index. These columns are not part of the index key (which SQL Server uses to order and search the index), but they are stored with the index pages.
The INCLUDE
option can significantly improve query performance when additional columns are needed by a query but are not part of the index key.
Dropping a primary key in any RDBMS is a critical operation that requires careful consideration, especially when there are related foreign keys in other tables.
The decision to drop a primary key is not to be taken lightly.
That said, this article walks through the process of how to drop a primary key in SQL Server, while highlighting important considerations.
Continue readingBy default, SQL Server creates indexes automatically when we do things like create certain constraints. We also have the option of creating indexes separately for our own (usually performance related) reasons. Either way, there may be times where we need to check what indexes we have in our database.
In this article, we’ll explore four ways to retrieve information about all indexes in a SQL Server database.
Continue readingIf you’re getting SQL Server error 1909 that reads something like “Cannot use duplicate column names in index. Column name ‘FirstName’ listed more than once“, it appears that you’re trying to create an index, but you’re listing the same column multiple times.
Each column can only be listed once in the index definition.
To fix this issue, make sure each column is listed only once.
Continue reading