index

Suppose I have 400 rows of people's names in a database. What's the best way to do a search for their names?

They will also search part of their name. Not only words with spaces. If they type "Matt", I expect to retrieve "Matthew" too. ...

Spatial index for geo coordinates?

What kind of data structure could be used for an efficient nearest neighbor search in a large set of geo coordinates? With "regular" spatial index structures like R-Trees that assume planar coordinates, I see two problems (Are there others I have overlooked?): Wraparound at the poles and the International Date Line Distortion of distan...

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...

Need index with sys_connect_by_path function? How to emulate it?

Hi, I have a self referencing table in Oracle 9i, and a view that gets data from it: CREATE OR REPLACE VIEW config AS SELECT c.node_id, c.parent_node_id, c.config_key, c.config_value, (SELECT c2.config_key FROM vera.config_tab c2 WHERE c2.node_id = c.parent_node_id) AS parent_config_key,...

How to know when to use indexes and which type?

I've searched a bit and didn't see any similar question, so here goes. How do you know when to put an index in a table? How do you decide which columns to include in the index? When should a clustered index be used? Can an index ever slow down the performance of select statements? How many indexes is too many and how big of a table do...

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...

two arrays defining 2d coordinates, as array indices, in matlab/octave

Hi, I have a 2D array, call it 'A'. I have two other 2D arrays, call them 'ix' and 'iy'. I would like to create an output array whose elements are the elements of A at the index pairs provided by x_idx and y_idx. I can do this with a loop as follows: for i=1:nx for j=1:ny output(i,j) = A(ix(i,j),iy(i,j)); end end H...

Why use INCLUDE in a SQL index

I recently encountered an index in a database I maintain that was of the form: CREATE INDEX [IX_Foo] ON [Foo] ( Id ASC ) INCLUDE ( SubId ) In this particular case, the performance problem that I was encountering (a slow SELECT filtering on both Id and SubId) could be fixed by simply moving the SubId column into the index proper rathe...

Why does SQL Server 2008 suggest I have the primary key column as an included column in an index

SQL Server 2008 is telling me to include the Primary Key in an index in the Included Column field. I thought the PK was automagically returned with all indexes? ...

index.php is not opening and running as download the file!

Hi friends, when I run the url at localhost for a php file like: http://localhost/project/admin/ it doesnt open the index.php, but gives panel for downloading the file with the message below :/ You have chosen to open which is a: application/x-httpd-php from: http://localhost What should Firefox do with this fil...

Beginner Question: For extract a large subset of a table from MySQL, how does Indexing, order of tables affect speed of query?

Sorry if this is too simple, but thanks in advance for helping. This is for MySQL but might be relevant for other RDMBSs tblA has 4 columns: colA, colB, colC, mydata, A_id It has about 10^9 records, with 10^3 distinct values for colA, colB, colC. tblB has 3 columns: colA, colB, B_id It has about 10^4 records. I want all the records fr...

Question about mysql indexes on low to medium cardinality columns

I have a general question about the way that database indexing works, particularly in mysql. Let's say I have a table with a million rows with a column "ClientID" that is distributed relatively equally among 30 values. Thus, this column is very low cardinality (30) relative to the primary key (1 million). Now, I understand that you ...

Explanation of sqlite_stat1 table

I'm trying to diagnose why a particular query is slow against SQLite. There seems to be plenty of information on how the query optimizer works, but scant information on how to actually diagnose issues. In particular, when I analyze the database I get the expected sqlite_stat1 table, but I don't know what the stat column is telling me. A...

R: How to get the index of a letter from a list A-Z?

I want to get the index of a particular letter, e.g. > match(LETTERS,"G") [1] NA NA NA NA NA NA 1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA Gives me that the letter exists, but I want it to return 6 in this case for the 6th element of the list. ...

How do I get the index of an item in an array?

var fruits = [ 'apple', 'banana', 'orange' ]; how do I find what index of the value "banana" is? (which, of course, is "1"). thanks ...

jQuery index selector

Hi, I'm trying to find out a way to know the index of a anchor tag inside a certain div (one div has multiple similar anchor tags), like this : <div> <a>first</a> <a>second</a> <a>third</a> </div> I'm using jQuery, but so far found no sollution to find the index of the anchor I have the mouse currently over. Any ideas? Cheers...

SQL Server - stored procedure suddenly become slow

I have written a stored procedure that, yesterday, typically completed in under a second. Today, it takes about 18 seconds. I ran into the problem yesterday as well, and it seemed to be solved by DROPing and re-CREATEing the stored procedure. Today, that trick doesn't appear to be working. :( Interestingly, if I copy the body of the sto...

MySQL load data infile - acceleration?

Hi folks, sometimes, I have to re-import data for a project, thus reading about 3.6 million rows into a MySQL table (currently InnoDB, but I am actually not really limited to this engine). "Load data infile..." has proved to be the fastest solution, however it has a tradeoff: - when importing without keys, the import itself takes about ...

Print Tuple Index in Python

This question falls into the "yes - this works, yes - this is ugly, yes - there is probably a better way" category. I want to use a regular expression to pull groups out of a match and then print the group number and the group value. It is to show someone how regular expressions work and to keep track of the values of each group. The cod...

Index page in Magento is way too slow, what can I do?

Weirdly, the index page of my magento commerce is very slow, while when you navigate the products, brands, searchs etc is very fast, but everytime you click on the banner to go for home or enter the website, it take ages to load I wonder what can I do about this? I don't know where to start, since I am new at magento. I thought I could ...