From: Mike Stephens Date: 2010-12-02T06:22:24+09:00 Subject: Re: A algorithm for finding the number Ben Bleything wrote in post #965426: > My point was that sqlite will never "bring the whole database > across" since it has no idea what that even means. Whilst this is not a Ruby issue, it is worth pointing out to those that don't already know, that client databases like Jet (and I would wager, SQLite) do not read all the database file if there are indexes they can use. Your program will read the first bit of the file and detect if there are applicable indexes. It will then fetch the index pages and look up the addresses (typically blocks that hold data pages) and fetch those from the file system. If you are looking at mickey mouse databases or stuff off a local drive, this might not be of any consequence, but if you start to get hundreds of thousands of records, or millions, it will dramatically cut down your fetches across the network and the work your program has to do to set up the data. If you have joins, the program might be able to do them purely off the indexes, so that next to no real data has to be fetched. The original poster was talking about MySQL as you rightly said. The first issue is therefore to check why the Select was running slowly - outside of Ruby. There are many reasons why that might be. Databases are sophisticated components that have millions of man hours lovingly invested in them. It would be entirely illogical to attempt to reinvent the wheel in your Ruby program. -- Posted via http://www.ruby-forum.com/.