Are all the indexes in SQL Server B Tree?
Surely primary keys and foreign should be hash based indexes?
Not all indexes in SQL Server are B-tree indexes (SQL Server 2012 added columnstore indexes which are a bit different), but there is no such thing as a hash-based index there (yet).
Here's a pretty straight forward article explaining that all indices are b tree indices in SQL Server:
http://msdn.microsoft.com/en-us/library/ms177443(v=sql.105).aspx
I think if you want to get more into the nitty gritty of specific RDBMS' implementations, you could try posting to http://dba.stackexchange.com
Related
I have to migrate SQL Sever 2008 database to the SQL Server 2012. 2008 is the enterprise version and 2012 is standard version. As we know, standard version does not support table partitioning.
The table which is partitioned in the enterprise version has 1 clustered and around 8 non-clustered indexed. I need to drop this partition but do not know how. Can someone please shed little light on how should I go about it?
Thanks.
To unpartition a table, you'll need to recreate all the indexes with a filegroup specification instead of parttion scheme. I suggest you drop all the non-clustered indexes and then rebuild the existing partitioned clustered index using CREATE INDEX...WITH(DROP_EXISTING-ON) with a filegroup specification. Then recreate the non-clustered indexes with a filegroup specfied.
Is there any way to convince SQL Server 2014 to do join elimination when joining columnstore indexed tables?
We have a standard dimensional model, with fact tables and dimensions, and there are views which join the facts with their many dimensions for the convenience of users.
When using conventional row store tables, we can take advantage of SQL's ability to eliminate the joins from those convenience views if they aren't necessary for a given query, by virtue of the fact that there are FK/PK relationships defined between the Facts and the Dimensions which allow the query planner to be certain that the join doesn't add or remove rows.
However, we'd like to convert the fact tables to columnstores, since they have massive performance improvements for the kinds of aggregate queries that are commonly done on the datamarts. But if we do so, we lose the ability to define the foreign keys, given that they aren't supported by columnstores. In turn, this prevents the planner from doing join elimination, making the convenience views do a whole bunch of unnecessary joining in many situations.
Is there any way to convince the planner to do join elimination, without the use of foreign keys?
To my knowledge for SQL Server 2014 this is impossible. You can easily get it with SQL Server 2016 Clustered Columnstore and the foreign keys ... :)
In some of the latest Cumulative Updates for SQL Server 2014 RTM & SP1 branches, there is one interesting bug fix that improve some performance, but I do understand that it is not exactly what you are looking for:
Query plan generation improvement for some columnstore queries in SQL Server 2014 or 2016
There is an option called "ColumnStore Index" available in SQL Server 2012.
Is it comparable with columnar databases such as Cassandra, HBase?
Few advantages of going with SQL Server 2012 can be:
It is Updateable
It is Relational
What other factors can be considered to choose between SQL Server 2012 and other Columnar databases in case faster query performance is a requirement.
I'm not sure what you mean by "it is updatable", but in SQL Server 2012 tables that have a columnstore index cannot be updated. You must first drop the columnstore index or you must partition around the columnstore index in order to support changes to the underlying data.
Also, columnstore indexes are useful in DW systems where very large amounts of data have to be aggregated and accessed quickly.
In SQL Server 2012 you have the alternative of indexed (materialized) views.
I have a database that will be used by multiple clients (local installs), the plan is to then copy the data to Azure to allow global reporting etc.
The database will be using GUIDs for it's primary keys.
What should I use for a clustered index on the tables, or does that not matter when adding data to Azure? Do I even really need a clustered index? Azure will have single copy of the database, with all client data in it if that makes a difference.
thanks all.
Although you are allowed to create (and have data in) a table without clustered index in SQL Server, this is not allowed in Windows Azure SQL Database ( WASD / SQL Azure). While you can have the table without clustered index in WASD as definition, no DML statement will be allowed to execute against such a table, i.e. you will not be able to do INSTERT/UPDATE/DELETE statements against table in WASD without clustered index. So, if by any chance data is going to the cloud, you should have a clustered index. For more info, check the Clustered Index Requirement in the Guildelines and limitations for Windows Azure SQL Database.
Some of the recommendations here are incorrect.
NEWSEQUENTIALID() is not allowed on SQL Azure.
In SQL Azure, a clustered index is absolutely required. You can create a table
without one, but you will not be able to add data to it until after
you add the clustered index.
In Azure, the clustered index is used for their back-end replication. Reference: http://blogs.msdn.com/b/sqlazure/archive/2010/05/12/10011257.aspx
I think that your best bet is to use a column with an Identity element as the clustered index, along with a non-clustered index on your guid column. I ran into this exact same problem and after quite a bit of research, it's the solution I eventually came up with. It's a bit of a pain to put together, especially if you already have data in production on Azure, but it seems to be the one that addresses all of the issues.
I feel like it would be simplest to use a NEWSEQUENTIALID, but that isn't an option on Azure.
Is it possible / practical to add a constraint (i.e., Primary Key or Index) to a view?
I am using SQL Server 2000 and the view queries multiple tables across 2 databases.
I know how to add a constraint to the tables that host/build the view. Those indexes are there. They just don't seem to carry over to the view.
Thought? Ideas? Suggestions?
Thank you.
If your views don't violate any of the long list of requirements, you can create a clustered index on your view in SQL Server 2000, and thus speed up queries quite a bit.
See:
SQL Team: Indexed Views in SQL Server 2000
MSDN: Improving Performance with SQL Server 2000 Indexed Views
Anything else isn't supported, as far as I know - if you want a constraint, you need to constrain the underlying base tables.
If you have a concrete problem with a view, maybe you need to explain in more detail. What do your base tables look like? What kind of data (and how much) is in there? What does your view definition look like? What are the queries you run against that view, and how does it behave - is it "just slow" or do you get wrong results, or what's the issue?