optimization

tips for optimizing a read-only sql database

I have a mid-sized SQL Server 2008 database that has actuarial data in it. All of the use cases for it are read-only queries. Are there any special optimizations I should consider given this scenario? Or should I just stick with the normal rules for optimizing a database? ...

mySQL ORDER optimizing

I have a query in which I am ordering a league table by a number of fields to handle the situation that some fields in the result may have the same value. I am curious as to why when subsequent fields aren't required for secondary ordering the query is still conciderably slower. Case in point is a table of items that are voted on. It co...

Which is the BEST way to optimize a web site for faster download and SEO?

Which is the BEST way to optimize a web site for faster download without affecting my ranking? How do I optimize my CSS file and images? ...

Optimal key for MySQL / InnoDB table with multi-part WHERE

Given a (simplified) table CREATE TABLE `transactions` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `CREATION_DT` datetime DEFAULT NULL, `STATUS_IND` int(11) DEFAULT NULL, `COMPANY_ID` bigint(20) DEFAULT NULL, `AMOUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`ID`), KEY `FKE7E81F1ED170D4C9` (`COMPANY_ID`), KEY `RPTIDX_CREATI...

How can I use .htaccess to send distant expiry headers on CSS and JS files?

I want my CSS and JS files to expire in the distant future. Can I do this with .htaccess alone? How would I do it? I know in the future if I change one I will need to force a redownload, something like this should work script.js?v=12 ...

Function approximation

I have a function, P(x0, x1, ..., xn) that takes 100 integers as input and gives as output an integer. P is a slow function to evaluate(it can range from 30 seconds to a couple of minutes). I need to know which values of points will maximize the yielded value from P. What techniques can I use to accomplish this? I know generally peop...

Avoid making copies with vectors of vectors

I want to be able to have a vector of vectors of some type such as: vector<vector<MyStruct> > vecOfVec; I then create a vector of MyStruct, and populate it. vector<MyStruct> someStructs; // Populate it with data Then finally add someStructs to vecOfVec; vecOfVec.push_back(someStructs); What I want to do is avoid having the copy ...

Scripts/Stylesheets: Consolidate locally or use CDN?

I can obviously do some limited testing of my own, but I'm hoping to hear from some people with real-world experience on at least medium-scale web sites. Two of the items on every "top 10" list for optimizing sites/bandwidth are: Consolidate as much JS and CSS as possible into a single file (to reduce round trips); and Use a Content D...

ASP.NET: Monitor application performance

Hi Geeks, I have an ASP.NET application which will be running in a web server (Windows Server 2003) for serving my intranet users. Now i would like to monitor the performance of the application: like memory management, unclosed db connection, etc... The ultimate aim is to make the application work optimized. What are the things i should...

css optimization

hello guys, I noticed that digg.com and google.com are using kind of css optimization in their gif header image. for example digg uses this image http://digg.com/img/menu-current.gif . can any one give me an idea why they are using this technique and how to do it in my own site? regards, ...

How to determine if memory is aligned? ( *testing* for alignment, not aligning )

Hi there, I am new to optimizing code with SSE/SSE2 instructions and until now I have not gotten very far. To my knowledge a common SSE-optimized function would look like this: void sse_func(const float* const ptr, int len){ if( ptr is aligned ) { for( ... ){ // unroll loop by 4 or 2 elements } ...

Should I be concerned about .NET dictionary speed?

Hello, I will be creating a project that will use dictionary lookups and inserts quite a bit. Is this something to be concerned about? Also, if I do benchmarking and such and it is really bad, then what is the best way of replacing dictionary with something else? Would using an array with "hashed" keys even be faster? That wouldn't hel...

is var x = new Stuff(); x.DoStuff(); faster than new Stuff().DoStuff(); ?

is var x = new Stuff(); x.DoStuff();faster than new Stuff().DoStuff(); ? I'm not sure why but I noticed in my code that the first method makes it faster, anybody knows which one is faster and why ? ...

References on statemachine optimization and code generation?

As a follow-up to my state machines as a C++-like language extension question, I'd like some more help. My compiler has been extended to parse my state machine extensions and now I'm beginning semantic analysis and code generation. There is a description on this page. Can anyone point me to good references on state machine optimization...

Retrieve 2 last posts for each category.

Hello, Lets say I have 2 tables: blog_posts and categories. Each blog post belongs to only ONE category, so there is basically a foreign key between the 2 tables here. I would like to retrieve the 2 lasts posts from each category, is it possible to achieve this in a single request? GROUP BY would group everything and leave me with only...

NHibernate + Fluent NHibernate + Oracle Index

I have a table with more than 10 000 000 rows. In TOAD this query works very well on it: select /*+ INDEX(x IDX_CASHFLOW_COMPLEX)*/ * from MYPR.CASHFLOW x where fk_debet in (21856, 21854, 21855) IDX_CASHFLOW_COMPLEX is index on 5 columns created by following script: CREATE INDEX MYPR.IDX_CASHFLOW_COMPLEX ON MYPR.CASHFLOW (FK_DEBIT...

Create a randomly ordered playlist from a table of songs and return the name of the current, next, and previous song?

Consider the following table: Song ---- SongID GUID Primary Key Name Varchar dateAdded DateTime I am creating a website that plays songs from the Song table. I want to generate a randomly ordered playlist for each visitor of the site that persists across requests without using any server-side storage (no session-style or database sto...

Slow mysql query. Any tips?

I have the below query... It works but it runs extremely slow. Was hoping someone might be able to give me a few tips to improve execution time? SELECT tb_clients.*, tb_clients_phone_fax.* FROM tb_clients, tb_clients_phone_fax WHERE tb_clients.client_id=tb_clients_phone_fax.client_id AND MATCH (client_company,client_description,client_k...

Would VS2008 c++ compiler optimize the following if statement?

if (false == x) { ...} as opposed to: if (!x) { ... } and if (false == f1()) { ...} as opposed to: if (!f1()) { ... } I think the if(false == ... version is more readable. Do you agree, or have another trick you can propose? Will it be just as fast? Thanks. This is why I do not like !x: if (25 == a->function1(12345, 6789) &&...

is there difference in speed between Dictionary.ContainsKey/Value and a foreach loop that checks for a certain key/value

is there difference in speed between Dictionary.ContainsKey/Value and a foreach loop that checks for a certain key/value ? ...