Re: Database tuning
От | Nevermind |
---|---|
Тема | Re: Database tuning |
Дата | |
Msg-id | 20011221221747.A43509@nevermind.kiev.ua обсуждение исходный текст |
Ответ на | Re: Database tuning (Antonio Fiol Bonnín <fiol@w3ping.com>) |
Список | pgsql-general |
Hello, Antonio Fiol Bonnin! On Fri, Dec 21, 2001 at 09:11:41PM +0100, you wrote: > >Then chose random one outside SQL, and then: > > > >select * from table where table.id = '$random_id'; > > > >This would be slower but will work for sure. > > > Probably even slower than original. Not sure, though. No, it should be faster that 9 seconds even if count of rows is very big :) Just verified on 100,000 records. It is about 1 second on my PIII-800/512Mb using perl as frontend. > > >Another approach -- select random id outside SQL from 0 (or 1) to > >maximum_id and then trying to select with 'where table.id = > >'$random_id'' until you've got > 0 rows in result. > > > The only drawback that I see to this approach is that it may not find a > result in a finite time. If IDs in table are pretty "Compressed" (c) you, as it is in our case it will work in VERY finite time :> > > Better: "Compress" your table so that it holds all continuous IDs. This > may be painful and long, but it will pay off in the end, if your table > is not updated often, so this operation only needs to be done once. Yes, I agree it will be _very_ painful if you have a lot of crosslinks in tables. > > I guess The Bible is not updated very often. ;-) We never should assume this. We don't know if God is preparing new release or just abandoned this book, maybe he has CVS somewhere... -- NEVE-RIPE
В списке pgsql-general по дате отправления: