I am very new to the software industry. I was assigned to implement keyup search or real time search for a web page. I need to search employee code.

For example, employee code is like TM-00001. If user types T then search box will show all the employee codes with prefix T. This is very basic and I can do this by using AJAX and select with a Like operator. But the database is large. We are using Oracle database.

What will be an efficient way to do the search?

2 Answers 2


Since this is for a user interface, you don't need to return all the records.

Limit the query to the top 51 records that match the search criteria. If you actually get 51 records back to the interface, replace the last one with some indicator ("...") to show that more records are available and the user should keep typing.

Something else to try - don't even attempt the search until you have some minimum number of characters.

  • Thanks for the reply. In the meantime I did some googling. Many of them are referring Apache Solr. Is it overwhelming for this simple search ? Dec 22, 2016 at 4:56
  • @seal: Apache Solr is a full enterprise search platform. You feed it information, it indexes it, you do searches that query those indexes for fast results. You can optimize your search for employee code in more lightweight ways, so if this is the only use case you have, then Solr might be too much.
    – Bogdan
    Dec 24, 2016 at 7:54

I want to add one thing to Dan Pichelman's answer. When the user starts typing display a spinner or some indicator that a search is underway but don't actually make the call to the server.

Instead, you should debounce the function call. If user types very fast you will make unnecessary calls to the database. But if you debounce the call you will make one call when the input settles.

There are various utils that can help you with that. And just for completeness sake, have a look at this too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.