2
I am developing an application in PHP and Jquery with the Codeigniter 3 framework. I am using Postgre and I have a database with more than 1 million registered records.
I made an autocomplete that searches by the name of a product in the bank, only as it searches in real time in the database starts to lock everything. I tested using a static array and worked 100%.
Computationally speaking as my database has many records, what would be the best way to do this?
PS: I’m using this jquery plugin (https://github.com/devbridge/jQuery-Autocomplete)
UPDATING
I am using Full Text Search, but I have not created any index for it. I will try to create it to see if it improves. See my code:
$query = $this->db->query("SELECT p.titulo AS value
FROM sistema.produto p
WHERE to_tsvector(p.titulo) @@ to_tsquery(?)
ORDER BY p.id_categoria
LIMIT 5", array($termo));
Andre, first not to mess with your application. if you use mysql, see about table partitioning. Create partitioning on these records and test.
– Rafael Salomão