Reputation: 8538
I might be a trivial questions, but I dare ask, please help me answer this questions.
I have been developing a PHP Mysql Application. Earlier, I used to use the following principle :
Now, I am following another approach as follows :
required
attribute in the form where input is necessarySo, in the second approach, I am using, I am making multiple MySQL query( around 30 queries) for each row update.
I know, it might not result in an optimal performance, but,
I would like your thoughts on the second approach, I am currently using in my application.
Upvotes: 0
Views: 68
Reputation: 8571
I think here confusion is for 2 points,
Generally, Code development and readability takes precedence over performance. This approach generally works well for small scale applications. As small scale applications will not face drastic performance issues.
But when Application grows in size then 1 query vs 30 queries will show the difference. Imagine if 100-1000 users use your application and with your 1st approach you will fire 100-1000 queries but with 2nd approach you will fire 3000-30000 queries on DB.
This can slow down your entire application. As no. of queries are directly proportional to,
In worst case, If your application has other forms,modules which are reading from DB as well then those queries will suffer from locking issue.
For greater performance and scalability, less no. of update queries should be preferred if they come with little coding overhead. And other jquery modules can used for validation which will also reduce coding effort.
Upvotes: 1
Reputation: 3757
You almost answered your own question I think, you are basically saying, I am on a crossroad where I can choose for script which executes 30 queries, or with a little more work, it could be 1 query.
I think it is a no go. It is much more efficient building a query statement with the values that are send. Also a best practice because mostly, you cannot predict how the application will grow.
I like html validation also, though browsers still handle this differently. Since most of my projects involves using jQuery, I tend to use jquery.validate plugin, which requires just a few lines extra to get a instant responsive form which is great for User Interaction. Ofcourse, serverside validation should always be in place.
Upvotes: 0