indexing

How to search a List(Of Byte) for two values using the Framework?

Is there a way of searching a list for more that one consecutive values? I've looking at Find and IndexOf but Find uses Predicates that only use the current value and IndexOf only takes byte parameters. I can code my own solution but I want to be sure that there isn't a solution already available to this common problem. Thanks in advan...

Python list.index question

Why does list.index throws an exception instead of returning a value like say -1? What's the idea behind this? To me it looks cleaner to deal with special values, etc than exceptions. EDIT: I didn't realize -1 to be usable, but in that case, how about a value of None? ...

python class __getitem__ negative index handling

Is there a common function to do this? Right now I'm just doing the following (and overriding __len__) idx < 0: idx = len(self) + idx if idx < 0 or idx >= len(self): raise IndexError, "array index (%d) out of range [0, %d)" %(idx, len(self)) ...

How do i use a hashing computed column after i have indexed a varchar(max) field?

I created a computed column of type varbinary and referenced a varchar(max) field. Now, how do i use or invoke it? thanks ...

python create slice object from string

I'd like to create a slice object from a string; right now the only way seems through a cumbersome hacky eval statement class getslice: def __getitem__(self, idx): return idx[0] eval("getslice()[%s, 1]" %(":-1")) thanks in advance. Edit: Sorry if the original prompt was not clear, the input in this case was ":-1". The point was t...

Do indexes suck in SQL?

Say I have a table with a large number of rows and one of the columns which I want to index can have one of 20 values. If I were to put an index on the column would it be large? If so, why? If I were to partition the data into the data into 20 tables, one for each value of the column, the index size would be trivial but the indexing ef...

Database Indexes

I need to develop a "naive" implementation of database indexes for use in a distributed environment. I know almost nothing about the subject, and I'm a bit pressured by time. I would love to hear some opinions, examples and algorithms on the subject. I'd like to be able to have a mental representation of what I need to implement. EDIT...

Hash Join Showing up on Full Text Query - SQL Server 2005

I have the following Query in SQL Server 2005: SELECT PRODUCT_ID FROM PRODUCTS P WHERE SUPPLIER_ORGANIZATION_ID = 13225 AND ACTIVE_FLAG = 'Y' AND CONTAINS(*, 'FORMSOF(Inflectional, "%clip%") ') What's interesting is that using this generates a Hash Match whereas if I use a different SUPPLIER_ORGANIZATION_ID (older supplie...

My IN clause leads to a full scan of an index in T-SQL. What can I do?

I have a sql query with 50 parameters, such as this one. DECLARE @p0 int, @p1 int, @p2 int, (text omitted), @p49 int SELECT @p0=111227, @p1=146599, @p2=98917, (text omitted), @p49=125319 -- SELECT [t0].[CustomerID], [t0].[Amount], [t0].[OrderID], [t0].[InvoiceNumber] FROM [dbo].[Orders] AS [t0] WHERE ([t0].[CustomerID]) IN (...

DB Index speed vs caching

We have about 10K rows in a table. We want to have a form where we have a select drop down that contains distinct values of a given column in this table. We have an index on the column in question. To increase performance I created a little cache table that contains the distinct values so we didn't need to do a select distinct field...

What are some best practises and "rules of thumb" for creating database indexes?

I have an app, which cycles through a huge number of records in a database table and performs a number of SQL and .Net operations on records within that database (currently I am using Castle.ActiveRecord on PostgreSQL). I added some basic btree indexes on a couple of the feilds, and as you would expect, the peformance of the SQL operati...

Google Desktop or Indexed Text File Search Within ASP.NET application

I have a folder with thousands of text files and I'd like to paste and search content into a web form and return matches in those files. Is there a way to do content indexing of those files and do these searches from within an ASP.NET application? What tools and techniques are available? ...

Where can I find useful item lists (SQL, or plain text) like sports, hobbies, and others?

GeoNames public geographic locations index is a very useful website that I have used to import a list of countries and cities into my web app. Now, are there any other public databases that would provide various useful lists? (Other than Wikipedia) I am looking for a list of sports, hobbies and similar items. ...

DrawItemEventArgs' "Index" property goes negative sometimes(C#)(RESOLVED)

Hi. I have an owner-drawn listbox control in my project. The problem is that sometimes the DrawItemEventArgs argument passed to my DrawItem event-handler has an Index property of "-1". It seems that this only happens when I scroll through the list box and then try to close my application; To avoid getting an exception I did something ver...

Bitmask to Array Index

Hello, Is there a simple way to convert a bitmask in to an array index? ie. If i've got an enum a = 0x01, b = 0x02, c = 0x04, d = 0x08, e = 0x10, etc and I want to store releated data in an array, is there a simple way such that i can convert a to 0, b to 1, c to 2. etc? Many thanks ...

are there best practices or tricks for indexing/monitoring a drive for files?

I need to find and monitor all the photos on a hard drive or a folder for a photo organizer. Currently I'm doing this naively: recursively traversing, manually marking folders as indexed, and repeating that process to catch when photos are added or moved. The problem is with a large enough folder tree this is very expensive, so I'm l...

comparing two fields in mysql -indexes?

I'm fairly certain I know the answer to this, but any ideas would be extremely helpful... First of all, this is MySQL 5.1.32-community. I have a large table (millions of rows, can't reduce the size - that is the reduced size) and the pertinent fields are two datetime fields. We'll call it date1 and date2. I need to run a select query...

Query performance of combined index vs. multiple single indexes vs. fulltext index

Background: I have a table with 5 million address entries which I'd like to search for different fields (customer name, contact name, zip, city, phone, ...), up to 8 fields. The data is pretty stable, maximum 50 changes a day, so almost only read access. The user isn't supposed to tell me in advance what he's searching for, and I also w...

Why too little index on chinese sites from google?

It is really strange that my company website has been release for long time already and I also submit sitemap to google but the index seem very very little (about 300 links only) which is really unbelievable. I do the same for the English portal it has very big index on google. I just wonder if google has problem with index portal in ch...

Best way to change clustered index (PK) in SQL 2005

I have a table which has a clustered index on two columns - the primary key for the table. It is defined as follows: ALTER TABLE Table ADD CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED ( [ColA] ASC, [ColB] ASC )WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] I want to remove this clustered index PK an...