optimization

PostgreSQL in memory database performance issue

Hi, I'm trying to speed up my django unit test, so I wrote custom database backend using for test purposes another tablespace located in memory. But I found no real advantages, the time my test running in memory remains the same. Then I created two similar tables using different tablespaces and run 10000 inserts for the each one. Time ...

mysql my.cnf for a 50gb of RAM server

Hello, I am having load problems on my database server (dual quad core 50 gb ram) load average: 4.26, 6.78, 11.25 here is the current my.cnf, can i optimize it? [client] port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] user ...

optimized this code and make it more dynamic

is there a way i can optimized this code and make this extensions on web.config settings so i can read from there and in future if i need to add or remove i should be able to do easily? if (fileExt.ToLower() == ".rtf" || fileExt.ToLower() == ".xls" || fileExt.ToLower() == ".doc" || ...

boost compressed matrix basics

I am confused on how the boost::compressed_matrix works. Suppose I declare the compressed_matrix like this: boost::numeric::ublas::compressed_matrix<double> T(1000, 1000, 3*1000); This allocates space for 3*1000 elements in a 1000x1000 matrix. Now how do I give it the locations which are the non-zero elements? When and how are the non...

Does LINQ to Entities expression with inner object context instance translated into sequence of SQL client-server requests?

I have ADO.NET EF expression like: db.Table1.Select( x => new { ..., count = db.Table2.Count(y => y.ForeignKey.ID == x.ID) }) Does I understand correctly it's translated into several SQL client-server requests and may be refactored for better performance? Thank you in advance! ...

Optimizing Python Code for Database Access

Hi, I am building an application with objects which have their data stored in mysql tables (across multiple tables). When I need to work with the object (retrieve object attributes / change the attributes) I am querying the sql database using mysqldb (select / update). However, since the application is quite computation intensive, the e...

Need help optimizing some Rails 2.3 ActiveRecord code

Hi everybody! (Hi Dr. Nick!) I'm trying to tighten things up for our app admin, and in a few places we have some pretty skeezy code. For example, we have Markets, which contain Deals. In several places, we do something like this: @markets = Market.find(:all, :select => ['name, id']) @deals = Deal.find(:all, :select => ['subject, disc...

Any tool that says how long each method takes to run?

some parts of my program are way slow. and I was wondering if there is tool that i can use and for example it can tell me ok running methodA() took 100ms , etc ...or so useful info similar to that. ...

Optimising a trivial MySQL query to get rid of filesort

Hi, I've got a trivial mysql query which isn't liked by the server really: SELECT zone_id, SUM(inc_sec) AS voucher_used FROM cdr_bill_2010_09 WHERE cust_id = 1234 AND voucher_id = 'XXXXXX' GROUP BY zone_id Now this should be really quick (and usually is) since there are indexes on both cust_id and voucher_id (voucher_id is chosen)...

Compiler Optimization with Parameters

Lets say you have some functions in some classes are called together like this myclass::render(int offset_x, int offset_y) { otherClass.render(offset_x, offset_y) } This pattern will repeat for a while possibly through 10+ classes, so my question is: Are modern C++ compilers smart enough to recognise that wherever the program sto...

Building an expression with maximum value

Given n integers, is there an O(n) or O(n log n) algorithm that can compute the maximum value of a mathematical expression that can be obtained by inserting the operators -, +, * and parentheses between the given numbers? Assume only binary variants of the operators, so no unary minus, except before the first element if needed. For exam...

What is faster in mysql, equal or greater on numeric columns?

I have numeric data with numbers representing the event that happened. Events can be public or private. I have 2 choices and I don't know which one to use (is faster). I can make 2 columns, 1 is the event column and the values are like 1...10. The other is the public/private smallint column that says if the event is public or private. ...

How-to ensure that compiler optimizations don't introduce a security risk ?

I have to write a Windows service that handles at some point confidential data (such as PIN codes, passwords, and so on). Those informations are needed for a very short amount of time: usually they are sent almost immediately to a smart card reader. Lets consider this piece of code: { std::string password = getPassword(); // Get the ...

How can I improve this algorithm for solving a modified Postage Stamp problem?

Son of Darts Problem was a contest on Al Zimmermann's Programming Contests that ended on 20 Jun 2010 : Suppose that you have a dartboard that is divided into R regions. Each dartboard region has a positive integer value associated with it. Further suppose that you have D darts and that you throw each of them at the dartboard. Each...

OpenGL ES on iPhone, How to Optimize for 2D (+ questions)

Hello ! I begin with OpenGL (and ES), so I have some (|| a lot) of troubles ^^ I Have two questions. 1°) I would like to have your opinion about my code. Because I don't know if all lines doing what they should do. The aim is to draw the lines of a polygon (but not to fill it, yet ^^). So I just want to do 2D on background transparent....

64-bit integer implementation for 8-bit microcontroller

I'm working on OKI 431 microcontroller. This is 8-bit microcontroller. We don't like to have any floating point operation to be performed in our project so we've eliminated all floating point operations and converted them into integer operations in some way. But we cannot eliminate one floating point operation because optimizing the calc...

Cookies: More but smaller or less but bigger?

Regarding web optimization, load-time, speed performance and assuming data size to be equal: Is it faster to have more cookies but smaller, or less cookies but bigger? For the technically inclined: would it be more efficient to concat values separated by a known delimiter resulting in a larger cookie size, or to have smaller cookies co...

Are there any good, modern, online guides to hand optimizing assembly code?

I'm working on some code which contains some (compiler generated) chunks of assembly code that we've identified are speed bottle necks. I know enough about assembly to muddle through and look for manual optimizations - I'm wondering, though, if there are any good, online guides that offer reusable techniques to be used in hand-optimizi...

Can I optimize this code??

I am trying to retrieve the data from the table and convert each row into CSV format like s12, james, 24, 1232, Salaried The below code does the job, but takes a long time, with tables of rows exceeding 1,00,000. Please advise on optimizing technique: while(rset1.next()!=false) { sr=sr+"\n"; ...

Fastest way to compare two images

Hi, I need to compare two images as fast as possible. I don't need to know the differences or anything else I just need to know if they are the same, yes/no, awesome. What is the fastest way to do this? Thanks, R. ...