I'm developing an application in PHP and Jquery with the framework Codeigniter 3. I'm using Postgre and I have a database with more than 1 million registered registrations.
I made an autocomplete that looks for the name of a product in the database, but as it searches in real time in the database, it starts to lock everything. I tested using a static array and it worked 100%.
Computationalally speaking as my database has many records, what would be the best way to do this?
PS: I'm using this jquery plugin ( link )
UPDATE
I'm using Full Text Search, but I have not created any indexes for it. I'll try to create it to see if it improves. Look at 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));