0

On OLX like Website , Anytime a user posts a new ad. It comes in top of the page. No search is involved in it. Which technology we can use to make such functions.

Suppose X is visiting my website abc.com. Should I fetch database each time and generate page dynamically ?

or There is a better approach to to that.

Ques no 2. Suppose X is searching a ad on my website abc.com. Should I run sql query on my database every time ?

Please guide me.

1
  • 3
    Basically you would have to generate it dynamically of course. Though in this case you could cache the page or parts of it. For the search part you would most likely want to use a search engine like Elasticsearch or Apache Solr. Commented Jun 8, 2016 at 7:35

1 Answer 1

1

Usually you have to query DB every time you render a page.

Q1 - Yes, you just have to select all items ordered by created date (well, you don't want to select ALL, but only how much you need for current page - see 'Pagination')

Q2 - Yes. Same as above. This might not work exactly as you want, because SQL databases are not search engines. In SQL DB you can only do simple search and filter. If you need better searching methods (search even when typos are present, ranking results, similar items, etc.) then you need search engine - Apache Solr for example)

Don't worry about querying database. It's designed to do this :) Start worrying about performance when you really fell page is running slow. When it happens you can start thinking about using 'cache' to store some database queries results.

EDIT - it's best to use some php framework to help you with some of this ;)

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.