|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
Search for a string in a text column (1 million rows+)
hi,
i have a table where a store data. there is also a text column where there is an average of 1000 chars in each entry. this table has more that 1 million rows. what i want, is to do a search to the text column for some text. how can i do this to speed up things? doing it with LIKE is not a solution (too much time) is there some way to get some results in milliseconds? question 2: count() on this table for all rows is also time-expensive. keeping the count of all rows in another table and updating it with every insert and delete is a solution? what would you suggest? thanx in advance |
|
#2
|
||||
|
||||
|
Did you look into full text indexing?
Also, if you keep fresh table stats you should easily have an approximate record count for that table (here) .
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Last edited by pabloj : March 31st, 2008 at 10:20 AM. |
|
#3
|
||||
|
||||
|
See the Tsearch2-functions in PostgreSQL 8.3 (latest version) or install Tsearch2 yourself in an older version of PostgreSQL (only takes a minute).
|
|
#4
|
|||
|
|||
|
Quote:
i found tsearch2.. seems pretty good , ill give it a try.. for my 2nd question, the problem is that i need a count(*) of a subset of rows, not all rows.. from 1.000.000 the matching may be up to 50.000.. how can i count these rows fast? |
|
#5
|
||||
|
||||
|
SELECT COUNT(*) FROM yourtable WHERE columnname = 'your value';
You do need an index on the columnname in the WHERE, otherwise it will slow down the query. |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > Search for a string in a text column (1 million rows+) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|