|Computer, MySQL, Tutorials Comments (0)|
Whenever you encounter a query slower than you expected, and you’re sure you’ve done everything in your power to ensure your tables are properly optimized and indexed, you might want to profile it. MySQL has an inbuild profiler, which allows you to see very detailed for what part of the query how much time has been spend.
To use it, follow these steps:
(1) Activate the profiler.
Since the profiler is deactivated by default we first have to start it.
SET profiling = 1;
(2) Execute your query.
(3) Find out the query id for profiling.
It will return you something like this:
Query_ID | Duration | Query ---------+-----------+----------------------- ... | ... | ... 29 | 0.0006200 | SHOW STATUS 30 | 0.3600000 | SELECT (your query here) ... | ... | ...
Now you know the query id is 30.
(4) Profile the query.
SHOW PROFILE FOR QUERY 30; // example
This will return you the details, which might look like this:
Status | Duration --------------------------------+------------------- starting | 0.000010 checking query cache for query | 0.000078 Opening tables | 0.000051 System lock | 0.000003 Table lock | 0.000008 init | 0.000036 optimizing | 0.000020 statistics | 0.000013 preparing | 0.000015 Creating tmp table | 0.000028 executing | 0.000602 Copying to tmp table | 0.000176 Sorting result | 0.000043 Sending data | 0.080032 end | 0.000004 removing tmp table | 0.000024 end | 0.000006 query end | 0.000003 freeing items | 0.000148 removing tmp table | 0.000019 closing tables | 0.000005 logging slow query | 0.000003 cleaning up | 0.000004
In this example, most of the time was actually spend sending the data from the server back to the client. Maybe try narrowing down the amount of data you get from the query. Maybe raise your query cache. Maybe do something different – its entirely up to your database, server and needs what to make of this result. But now you know where to look!
|Computer, Tutorials Comments (0)|
Many developers think of Firebug as the mother of all web tools. There’s a reason for it, because Firebug contains sophisticated tools to do nearly everything you need being a web developer, starting with little css experiments, debugging complex jscript-applications, profiling of web pages and many more.
Not commonly known is how to create your own logs using JScript.
For example, …
prints exactly this in your Firebug console.
You can refine this, since most of you distinguish informations, warnings, errors and debug output.
console.debug('Debug'); console.info('Information'); console.warn('Warning'); console.error('Error');
Debugging variables can be helped, too.
var banana = 1.234; var orange = "Test"; console.log("my %a has the value %d", orange, banana);
If you have the need to group log output, just do it like this:
console.group('myGroup'); console.info('Info1'); console.debug('What did I want to know?'); console.groupEnd();
Even more features, p.e. timing values, stacks and so on, are documented here.
By the way:
Most of these features have already found their way into the debugger used by Google Chrome!
|Computer, Tutorials Comments (0)|
Maybe you’ve encountered this before: there is no direct way to add a simple command like WAIT x seconds in DOS. While forging an easy solution for a simple task, I’ve found a nice, create way of solving this:
PING 220.127.116.11 -n 1 -w 25000 >nul
Yes, indeed. The PING-command is used to wait.
A few additional explanations:
- The IP adress 18.104.22.168 refers to your first network device/card, so this adress should in most cases be available to your system.
- The additional parameter
-n 1sets the numbers of pings to 1.
- The parameter -w is the wait duration, keep in mind these are miliseconds, so the value 25000 actually stands for 25secs.
>NULpipes the standard output stream to the null-device, so every entries or responses to this stream are accepted and forgotten.
Of course, usually I try to avoid using a WAIT-operation in scripts at all, and this ain’t a very exact technique. It simply does the job for most tasks where a WAIT-command might be required.
|Film & Fernsehen Comments (0)|
An article indicates that a tiny film company named Warner is starting to work on a movie adaption of Otherland, the great science fiction epic by Tad Williams. Brave!
|Aktuelles Comments (0)|
Tolles Datum: 11.11.11