Performing Functions in MySQL vs. PHP [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I just learned that you can perform loops and things like that directly in MySQL rather than using PHP for them. Which is more efficient hardware-wise? When would it be advantageous to use each over the other?
Thanks!

It is a case of horses for courses. Generally the efficiency of PLSQL is TERRIBLE when compared to the efficiency of a programming language - but if the difference is that you can run one very simple statement in a database and return 100 rows of data, versus returning a million rows of data and processing them all code to get to the same 100 rows... well you see where this is heading.
Generally speaking, it comes down to experience - but most of all it comes down to testing it out for yourself. If you have a long job that you think might be better done in another part of the code, or in another system - write it and test it. See what works better. There simply isn't a "one shoe fits all" answer for this.

Related

Should WordPress Page Builders be avoided by competent hard coders? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Do WordPress Page Builders increase page load speed and as such, should these be avoided by those competent at hard coding?
Or is there something else that I am missing as the only real value, I can see with Page Builders, is that they help reduce time spent on coding.
Use code. Page builders add additional load time. Your site may also become less portable and maintainable because a bulk of the design for your site could be stored in the database. It really depends on the situation. I would assume code to be a little cleaner though.
Page builders add additional code which are mostly unnecessary so it means the page is heavier and therefore the speed is lower, i would recommend to always make the code by a coder, but if the page just have little content then probably a page builder cold come in handy

MySQL Algorithm vs Query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
You find a lot of info on this online. But not what the exact work around of the use of Algorithm is in MySQL. The real basics, if you will..
What a query is, is obvious, of course. What Algorithm does, remains unclear.
Main reason for this question is: to improve profiling & matching records to known users. (In this case: to match docs in a database to users that need them)
Some examples of the usage of it are highly appreciated!
Algorithm is a keyword used with create view in MySQL. The documentation does a pretty good job of explaining it.
The short answer is that MySQL supports two methods of handling views: either "merging" the view definition in the calling code or creating a temporary table. The first is called MERGE and the second TEMPTABLE. In general, MERGE is faster, but most views are TEMPTABLE because of the restrictions on `MERGE.

Which is faster ASP.NET or PHP [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I need to do some server side programming to read through a database. The database will have about a thousand entries per user. Reading through the database will take a little while, so I need to know which language is faster, ASP.NET or PHP. Thank you.
This question has already been asked here many times and it's impossible to answer such question. Do a research on both the languages PHP and ASP.NET and than ask your self which one is best for this task. Both the languages are very fast but it depends on you what you want to take
ASP.NET and PHP are very close in terms of speed. PHP tends to be a little faster, see here: http://www.comentum.com/php-vs-asp.net-comparison.html. As you will see, most of the larger companies that have to read though very large databases tend to use PHP. But since ASP.NET and PHP are so close in rearms of speed, you should take into account which one is more common. In this case, PHP is far more common.
Note: PHP is written in C, so it may be faster to use C rather than PHP.
Good luck!

PHP does lots of type checks slow down your code? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a couple of classes that deal with objects, arrays and strings.
I was wondering what the impact on performance is to do type checks like:
is_object(), is_array() and is_string();
I use these quite a lot in my code.
In functions that are being called many thousands of times, is it better to assume the arguments passed is the correct type or check to prevent errors?
Is there any resource where you can have a look at the performance weight of php functions?
You can find out yourself.
Store the current time in milliseconds at the start of your script, run a loop which does a type check several thousand times, and compare the time at the end of your script with the time at the start of your script.
I prefer to use these checks.
You can save few milliseconds by avoid this checks. But if you didn't check it, there is a possibility to crash web page or some other issue.
So better to avoid those issues. If you are repeating any function related with database, it may cause a performance issue. But these small checks will not cause performance issue.
Lets think about it, before take your decision.

Best performance? treat data in DB and get result directly OR get result and then work on it? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a small question about performance during dev (web especially) :
Is it better to :
perform operations directly on the DB and retreive a "ready" result
OR
retreive the data from the DB and then do the operations?
Mat is right (see comments): there is no general answer to that. It depends on the structure of your data, on the queries you want to run and on your database system.
Nevertheless I would say, in most traditional cases it is better to join, filter, group, cumulate and sort your data directly in the DB - just because your DB is built to perform exactly this kind of tasks. If your data structure and indexes are built up right, it will be hard to write code beating the database in terms of performance on this actions.
Indeed, there are complex queries where it is better to split it up and do some work in your code. But unless you have more than 10 tables involved or big sub queries, you should not think about this to much.

Categories