Non spatial indexes in Oracle - database

I'm trying to create a non-spatial index on two columns, one of which is a geometry column (SDO_GEOMETRY). It appears from the documentation that it is possible but I'm unable to create one.
An excerpt from the Oracle documentation:
For each spatial column in a non-SPATIAL index except POINT columns, a
column prefix length must be specified. (This is the same requirement
as for indexed BLOB columns.) The prefix length is given in bytes.
Here's the query I'm trying to execute to create the index:
create index multiple_column_index on TestDB (ID, SHAPE) tablespace test;
The SHAPE column is the geometry column here. The error I'm receiving is:
SQL Error: ORA-02327: cannot create index on expression with datatype ADT
02327. 00000 - "cannot create index on expression with datatype %s"
*Cause: An attempt was made to create an index on a non-indexable
expression.
*Action: Change the column datatype or do not create the index on an
expression whose datatype is one of VARRAY, nested table, object,
LOB, or REF.
I've not applied the column prefix here as I couldn't find any documentation that explains its usage.

There's no way to index a spatial column as a part of a B-Tree index.
If you have a spatial column on one of your tables — you have to create a spatial domain index on that column, in order to use spatial functions.
There's no other way to index those columns.
Spatial domain indexes are pretty complex - you got many interesting options when creating it.
One can achieve great performance configuring (and using) those indexes correctly.

Related

I am trying to implement always encrypted on a partitioned table on column that is not used for partitioning the table

I am trying to implement always encrypted using deterministic type on a partitioned table on column that is not used for partitioning the table.I am getting below error:
Column 'SubsidiaryId' is partitioning column of the index 'XYZ'.
Partition columns for a unique index must be a subset of index key.
Cannot create Index or constraint. See previous errors.

size/length limitation of array type in PostgreSQL

I'm working on a web project with PostgreSQL as a databases. I'm trying to build a structure of the web's databases that include a vector space model table.
I created a table with attribute terms and docId[] where docId is the document ID of the term. Type of the docId is integer[]. So I can input a term with the document list that include the term in one single array. But the docId's array of term may contain a lot of entries.
So my question is: what is the max size of a 1-dimension array in Postgres?
There is no size limit on Postgres arrays. There must be limits on row or column size, but that would run in the millions of entries.
A more SQL way to relate term to document is a 1 to many relation. This is implemented like:
table term: columns term_id, term, document_id
table document: columns document_id, summary, ...
The document_id column in the term table is called a foreign key.
I didn't find any limitation in number of elements in array, but there is in field size. Maximum size of field in PostgreSQL is 1GB, so it is approximately 268435456 elements in array. Be aware that indexing such array or searching through it would probably be useless.

Creating Full Text index on temporary table

When I create a full text index on a temporary table #Table in a query? I got Invalid name object #Table.
Is creating full text index possible in sql server?
According to the documentation, no it is not possible:
A full-text index must be defined on a base table; it cannot be
defined on a view, system table, or temporary table.
This should be clarified to point out that since the version that documentation was written for, indexed views were added to SQL Server, and documentation there states that:
one full-text index is allowed per table or indexed view

Cannot use a CONTAINS or FREETEXT predicate on table or indexed view

I am trying to modify a stored procedure ( adding a new column in select statement) but I am getting this error:
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'vwPersonSearch' because it is not full-text indexed.
When I try to create a Full text index on view 'vwPersonSearch' using SQL server 2008 R 2 management studio, I am getting this error:
A unique column must be defined on this table/view.
Please suggest solution to it
To create a full text index, you must specify a key index, which must be a unique, single-key, non-nullable column. An integer column type is recommended for best performance.
See http://technet.microsoft.com/en-us/library/ms187317.aspx for more details.
You may alter a column to be unique if that's one that could be or add an id of some sort to do that part.

Composite and Covering index

What is the diffrence between composite index and covering index in Sql Server ?
A covering index is a composite index that contains every column you are currently retrieving with your select statement and that participates in the where clause. It is one of the best ways to improve query performance substantially.
A covering index is a composite index that covers (hence the name) all columns that are necessary to fulfill a query or a join condition.
There is nothing special about SQL server here, these are generic designations.
A composite index is also a covering index when the index contains your search criteria and all the data your query is attempting to retrieve. In this example:
SELECT a,b,c FROM Foo WHERE a = 'FooFoo'
A covering index would contain column a (your search predicate) as well as the columns b and c.
In this case SQL Server is optimized to return those values found in the index and does not need to make an additional look up in the actual table. If b and c are frequently returned but rarely searched on then the index might be set up such that b and c are included in the index but not indexed.
Before SQL Server 2005 DBA's would add additional 'covering' columns to their indexes to achieve this optimization. In SQL Server 2005 an additional feature was added that allowed you to include covering columns in the leaf nodes of the index that were not part of the index tree. When creating an index you can specify additional 'covering' columns in the include clause. These columns will not be indexed but added to the leaf node of the index saving SQL Server from looking up the additional data in the main table. Adding the data to the include clause saves SQL Server the overhead of adding the additional data to the search tree while gaining the optimization that a covering index brings.

Resources