I have a text field in my web app where I want to do auto-completion (e.g. the user types "St" and I can suggest "Steve"). The names I'm matching against are in a SQL database table of users. My question is, how can I make this happen in a way that will scale to massive amounts of users?
There's DB full text search or something like Lucene. Would that even be appropriate for a "starts with" query like this?
Is there a way to set up a normal DB index for "starts with" type searches?
Any other ideas that I'm totally missing?
Any help would be appreciated. Thanks.
Go to Tools -> Options -> Text Editor -> Transact-SQL -> IntelliSense -> Enable IntelliSense, as shown in the snippet below. Open New Query Window -> Go to Edit -> Expand IntelliSense -> Click Refresh Local Cache or press the shortcut key (CTRL + SHIFT + R) to refresh the local cache as shown in the snippet below.
Automating the executing of SQL queries can be handled by any client tool which can be scheduled. Typical solutions are in place by the database vendor already. Like Microsoft SQL server has the SQL Server Agent and MySQL has the MySQL Event Scheduler.
Microsoft SQL Server Management Studio allows users to create and edit SQL queries and manage databases. Microsoft SQL Server Management Studio has been on the market for a long time.
Open SSMS, click Tools -> Options -> Expand Text Editor -> Expand Transact-SQL and click on IntelliSense as shown in the snippet below. Under Transact-SQL IntelliSense Settings ensure “Enable IntelliSense” checkbox is enabled.
These should do the job as long as you have an index on the name column.
SQL Server:
SELECT TOP 10 name FROM names WHERE name LIKE 'St%'
MySQL (according to Bart J):
SELECT name FROM names WHERE name LIKE 'St%' LIMIT 10
Oracle:
SELECT name FROM names WHERE name LIKE 'St%' AND rownum < 10
If you have an ordered index on the field you want to autocomplete then it can be used in a "starts with" style query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With