optimization

Optimize MySQL query to avoid "Using where; Using temporary; Using filesort"

Hey all, I built a custom forum for my site using MySQL. The listing page is essentially a table with the following columns: Topic, Last Updated, and # Replies. The DB table has the following columns: id name body date topic_id email A topic has the topic_id of "0", and replies have the topic_id of their parent topic. SELECT SQL_CA...

Programmatic control of python optimization ?

I've been playing with pyglet. It's very nice. However, if I run my code, which is in an executable file (call it game.py) prefixed with the usual #!/usr/bin/env python by doing ./game.py then it's a bit clunky. But if I run it with python -O ./game.py or PYTHONOPTIMIZE=1 ./game.py then its super-smooth. I'm don't care m...

Looking for MySQL optimization and fine-tuning tips

Howdy peeps. I hope you can help me with this one. I got a twitter service ( http://foller.me ) which is about to be updated to public beta 2, but I don't want to do this until I could give the pages out in at least 2 or 3 seconds. The current version is simple enough, but the dev version I'm working on is quite complex. It's all about...

Efficiently querying a 15,000,000 rows table in MySQL

Consider the following database tables: Table "messages" with 13,000,000 rows (one row per message). Table "users" with 3,000,000 rows (one row per user). The following query is used to fetch a bunch of messages and the corresponding users: SELECT messages.id, messages.message, users.id, users.username FROM messages INNER JOIN users...

Choice of MySQL table type for non-critical webapp data (MyISAM vs. InnoDB)

Consider this scenario with the following assumptions: The database is used for a non-critical webapp. Query speed is of vital importance. The read/write patterns are roughly >95 % reads and <5 % writes. The database is backuped up daily using mysqldump. The is no need for transactions or advanced crash recovery. If the database crash...

QP solver for Java

I'm looking for a good easy to use Java based Quadratic Programming (QP) solver. Googling around I came across ojAlgo (http://ojalgo.org). However, I was wondering if there are any other/better alternatives. ...

Mysql optimization

I'm currently trying to optimize a MYSQL statement that is taking quite some time. The table this is running on is 600k+ and the query is taking over 10 seconds. SELECT DATE_FORMAT( timestamp, '%Y-%m-%d' ) AS date, COUNT( DISTINCT ( email ) ) AS count FROM log WHERE timestamp > '2009-02-23' AND timestamp < '2020-01-01' AND TYPE = 'play...

What causes a page to render slow?

I am puzzled. I looked at the trace of a pagecall that was "slow" to load according to my boss, causing the page to partially load, and then "jump" to the memorized scroll-place on a postback. I found out eventually, using my trace, that my whole loading, from Begin PreInit to End Render, took 1.94 seconds, 1.5 of which are spent betwee...

Optimize PHP function

Hi, I have a function that detects all files started by a string and it returns an array filled with the correspondent files, but it is starting to get slow, because I have arround 20000 files in a particular directory. I need to optimize this function, but I just can't see how. This is the function: function DetectPrefix ($filePath, $...

Javascript: Optimizing details for Critical/Highly Processed Javascript code

Hi, I've been looking through a lot of Javascript Optimizing and most of them talk about string concatenation and a few other big ones found here, but I figured there had to be more details that you can optimize for when speed is critical and the processing of those pieces of code is very high. Say you run this code for some reason: (u...

Faking IGrouping for LINQ

Imagine you have a large dataset that may or may not be filtered by a particular condition of the dataset elements that can be intensive to calculate. In the case where it is not filtered, the elements are grouped by the value of that condition - the condition is calculated once. However, in the case where the filtering has taken place,...

What are some of the database optimizations for multi-tenant applications.

Salesforce’s secret sauce: It queries its databases with “The Multi-Tenant Optimizer" So exactly what could this practice be comprised of? ...

Is there a more efficient way to reconcile large data sets?

I've been tasked with reconciling two big data sets (two big lists of transactions). Basically i extract the relevant fields from the two data sources into two files of the same format, then compare the files to find any records that are in A but not in B, or vice versa, and report on them. I wrote a blog entry on my best efforts achievi...

How to optimize mysql indexes so that INSERT operations happen quickly on a large table with frequent writes and reads?

I have a table watchlist containing today almost 3Mil records. mysql> select count(*) from watchlist; +----------+ | count(*) | +----------+ | 2957994 | +----------+ It is used as a log to record product-page-views on a large e-commerce site (50,000+ products). It records the productID of the viewed product, the IP address and USER_...

Anyone care to help optimize a MySQL query?

Here's the query: SELECT COUNT(*) AS c, MAX(`followers_count`) AS max_fc, MIN(`followers_count`) AS min_fc, MAX(`following_count`) AS max_fgc, MIN(`following_count`) AS min_fgc, SUM(`followers_count`) AS fc, SUM(`following_count`) AS fgc, MAX(`updates_count`) AS max_uc, MIN(`updates_count`) AS min_uc, SUM(`u...

How to design acceptance probability function for simulated annealing with multiple distinct costs?

I am using simulated annealing to solve an NP-complete resource scheduling problem. For each candidate ordering of the tasks I compute several different costs (or energy values). Some examples are (though the specifics are probably irrelevant to the question): global_finish_time: The total number of days that the schedule spans. split_...

Should you accurately specify column types in MySQL?

When I define columns in MySQL I generally use int, varchar(255), text and the occasional enum for boolean. What are the benifits of accurately specifying column types rather than just leaving them at maximum? For example a password field encoded as MD5 will never exceed 32 characters so is there a tangible performance gain from using ...

How can I optmize a MAX date query relating to a other table entity

I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because the id field of the table containing the maxDate needs to relate to the other table. The working query is: SELECT maxReadDate, Equip.idProtocol FROM Equip, ( SELECT idEquip as idEquipTot, MAX(readDate) AS maxReadDate ...

Efficency of Comparisons in C++? ( abs(X)>1 vs abs(x) != 0)

I know- Premature optimization. But I've got code that's supposed to find out if a position is changed vs a cached position. Current code is: if(abs(newpos-oldpos) > 1){ ..... } Is it more efficient to use the following? if(abs(newpos-oldpos) != 0){ .... } Why or why not? I'm currently debating it my head which is more re...

PHP cli Memory usage optimization

Hello I am trying to code a custom url_rewriter for squid. & also with using some other url_rewriter programs like squidGuard so have to use a wrapper to able use both or any other program. when i try to loop with php. (that's the way how squid communicates with external programs. STDIN/STDOUT. it gives you a url & you have to sen...