D
D
del9937882017-09-27 13:50:29
MySQL
del993788, 2017-09-27 13:50:29

What filters data faster: sql or js?

There is a database. There is a lot of data in the database. The database has a price column. I need to get only those rows where the price, for example, will be from 100 to 200. What is the best way to do it: get all the data and filter it using js, or immediately make the necessary sql query to the database with the necessary price range parameter? What will work faster and will strain hosting less?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
d-stream, 2017-09-27
@d-stream

I imagine a picture: a person walks with a mobile phone in roaming, opens a website, and a hundred gigs of data falls out to him, so that later the zhabascript searches there and finds the necessary hundred bytes ....

V
Vitaly Stolyarov, 2017-09-27
@Ni55aN

Of course SQL'om it is better to do it. With a couple of dozen records, there may not be a noticeable difference in performance, but if there are a thousand records in the database, then it will be very expensive to read them all and transfer them to the client

E
Egor Zhivagin, 2017-09-27
@Krasnodar_etc

It is normal to make the necessary query to the database + put indexes there + fasten the cache. Everything will fly.

There is a lot of data in the database
- how much is this? At least for the sake of curiosity.
It is impossible to give all the data to client-side JS, of course.

S
SagePtr, 2017-09-27
@SagePtr

The easiest way is to filter on the database side, especially if you set an index on the field by which the filtering occurs. Indexes help not to read the entire table from disk, but only the necessary rows that fall under the criterion, and the operation of reading from disk is one of the most difficult on the server side.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question