indexing

query execution plan : missing index

There are two tables that I join them together, one of them is a temp table and I create an index after creating the table. But it is said in the query execution plan above. what should I consider to convert all scan operations to seek operations? There are parts which are joins and where conditions... Regards bk ...

SQL Index Question: Why does SQL Server prefer this NONCLUSTERED index to a CLUSTERED one?

I have the following query: SELECT COUNT(*) FROM FirstTable ft INNER JOIN SecondTable st ON ft.STID = st.STID As you can guess, "STID" is the primary key on "SecondTable"... and "FirstTable" will have a pointer to that second table. Here are the indexes that I have: FirstTable: NONCLUSTERED INDEX on column "STID" Sec...

Do DB indexes take same amount of disc space as column data?

If I have a table column with data and create an index on this column, will the index take same amount of disc space as the column itself? I'm interested because I'm trying to understand if b-trees actually keep copies of column data in leaf nodes or they somehow point to it? Sorry if this a "Will Java replace XML?" kind question. U...

Can a database index span tables? I'm on Postgres

Is it possible to create an index that has as one of its columns values from another table? Example: model Pet primary_key id foreign_key Species end model Species primary_key id int genus end Assume there's a lot of kinds of species, with fewer types of genuses. I'd like to create an index on the Pets table by Genus. Can i...

mysql: Duplicate entry '0' for key 'PRIMARY' and bizarre ID behavior

See log below. (Snipped just for brevity; unsnipped @ http://pastebin.com/k9sCM6Ee) In short: somehow rows are getting assigned ID 0. When this happens, it blocks inserts, even when those inserts aren't actually conflicting with ID 0 (although that really shouldn't happen in the first place). Although it is heavily read and very heavil...

How to refer to items in Dictionary<string, string> by integer index?

I made a Dictionary<string, string> collection so that I can quickly reference the items by their string identifier. But I now also need to access this collective by index counter (foreach won't work in my real example). What do I have to do to the collection below so that I can access its items via integer index as well? using Syste...

Vectorization of index operation for a scipy.sparse matrix

The following code runs too slowly even though everything seems to be vectorized. from numpy import * from scipy.sparse import * n = 100000; i = xrange(n); j = xrange(n); data = ones(n); A=csr_matrix((data,(i,j))); x = A[i,j] The problem seems to be that the indexing operation is implemented as a python function, and invoking A[i,...

index help for a MySQL query using greater-than operator and ORDER BY

I have a table with at least a couple million rows and a schema of all integers that looks roughly like this: start stop first_user_id second_user_id The rows get pulled using the following queries: SELECT * FROM tbl_name WHERE stop >= M AND first_user_id=N AND second_user_id=N ORDER BY start ASC SELECT * FROM tbl_...

SQL Overlapping and Multi-Column Indexes

I am attempting to tune some stored procedures and have a question on indexes. I have used the tuning advisor and they recommended two indexes, both for the same table. The issue is one index is for one column and the other is for multiple columns, of which it includes the same column from the first. My question is why and what is the di...

Python: Indexing list for element in nested list

I know what I'm looking for. I want python to tell me which list it's in. Here's some pseudocode: item = "a" nested_list = [["a", "b"], ["c", "d"]] list.index(item) #obviously this doesn't work here I would want python to return 0 (because "a" is an element in the first sub-list in the bigger list). I don't care which sub-element...

typo3 Indexed Search Engine - not all the page content is indexed

I have a typo3 site with Indexed Search Engine extension... The problem is that not all the content is indexed (with debug option activated in conf content not all the page is present but the page size is corect), only the firts part of the page (witch is the head/title and the begining of the menu...). So for every page the words are on...

Lucene index with multiple fields of the same nature

Each Lucene doc is a recipe, and each of these recipes have ingredients. Im working towards being able to search the ingredients and give a result that says two ingredients matched out of four. (for example) So how can I add the ingredients to the doc? In solr I can just create multiple fields of and it would save them all, I might be...

Filter and Find from in-memory data sets

I have several medium-sized data sets in-memory that I need to be able to filter and find information from quickly. The data sets are small enough that I don't want to take the performance hit of going to a database every time I need an entry but large enough that I really need to index the data somehow. Currently, I'm using POCO object...

How XOR Hash Works + Picking A Key

I've been tasked with implementing an XOR hash for a variable length binary string in Perl; the length can range from 18 up to well over 100. In my understanding of it, I XOR the binary string I have with a key. I've read two different applications of this online: One of the options is if the length of my key is shorter than the string...

How should I index a table to optimize to find null?

I've got a table and the only time I'll be selecting or doing anything against it is to find all the rows where a certain date column is null. From there, I do stuff with it and update that column, and likely I'll never visit that row again, with the exception of auditing purposes. So, is there a best practice to ensure that the rows w...

MySQL: Indexing large amount of columns with varied queries

Hey guys.... I really hope someone can help me here as I can't seem to get an answer anywhere :( Basically I'm working on a large table so indexes are pretty important, but it's basically a table that has several different fields that are searchable..... so the way the columns are queried has probably 100's of different variations, so c...

MySQL forgot about automatically creating an index for a foreign key?

After running the following SQL statements, you will see that, MySQL has automatically created the non-unique index question_tag_tag_id_tag_id on the tag_id column for me after the first ALTER TABLE statement has run. But after the second ALTER TABLE statement has run, I think MySQL should also automatically create another non-unique in...

[SQL server 2K] Bookmark Lookup

Hi folks: I see a node named "Bookmark Lookup" in my execution plan. What does it means? It costs most among steps inside the plan. Any suggestion to optimize it? ...

Createing a new Index in SQL when current records don't meet that index

Hey all- I'd like to add an index to a table that already contains data. I know that there a few records currently in the table that are not unique with this new index. Clearly, MySQL won't let me add the index until all of them are. I need a query to identify the rows which currently have the same index. I can then delete or modif...

Is a primary key automatically an index?

If I run Profiler, then it suggests a lot of indexes like this one CREATE CLUSTERED INDEX [_dta_index_Users_c_9_292912115__K1] ON [dbo].[Users] ( [UserId] ASC )WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY] UserId is the primary key of the table Users. Is this index better than the...