Friday, September 24, 2010

Update multiple records with single query, or Bundle Record Update

Actually it's a lie, it's not a single query, it's 3 queries, but it's still much more sufficient if you deal with more than 3 records to be updated with different values.

So, the problem is to run lot of update queries like:
update table_name set value_column='value1' where key_column = key1;
update table_name set value_column='value2' where key_column = key2;
...
update table_name set value_column='valueN' where key_column = keyN;

If you have N more than 3, then you should test the performance of the following approach:
1. create temporary table temp_table(k int,v varchar);
2. insert int temp_tabl values
(key1,'value1'),
(key2,'value2'),
...,
(keyN,'valueN')

3. update table_name, temp_table set
table_name.value_column=temp_table.v
where table_name.key_column=temp_table.k

For ~50 records, it works ~2 times faster, so think about it.

Как-то-так

Friday, September 3, 2010

Eclipse PDT 64Bit Windows 7 problem

This was the first thing that I thought is happening - my PDT IDE is working too slow because of incompatibility with my 64bit OS. I was 100% sure... because PDT "ate" ~80-100% of one of my 4 CPUs. I hate these moments thinking that my QuatroCore SUCKS runing java app :( ... Thanks Lord I was wrong.

Just turn the Outline view OFF and CPU back to 10-20%... too many classes , methods, properties are killing Outline view in Eclipse PDT. Don't keep it constantly open.


Wednesday, September 1, 2010

SD Card size must be at least 9MB

If you receive this error when creating new Android Virtual Device (AVD) even though you've input much more than 9MiB into "SD Card size" field... Consider following advice:

Here is some additional detail on what sizes are considered valid or invalid when generating a new AVD (set to MiB): 0-8: invalid 9-2047: valid 2047-4104: invalid 4105-6143: valid 6144-8200: invalid 8201: valid

Taken from here

Installing Android SDK

What a wonderful day is when you start learning new things...

Today was one of those, cuz I've started with Android SDK. Downloaded (for Windows) it and run "SDK Setup.exe", then wanted to create new Virtual Device (AVD) and failed, cuz "Target dropdown" was disabled and New AVD Wizard complains that is should be selected.

I've started googling, got many advices, most of them too complicated to be true for my situation. From the bottom of my "IMHO" I felt that there should be easier way, and so it was.

I've noticed the error I ignored on the first run, something about "Setup was not able to fetch smth via https"...

So the first thing you should do after downloading and running Android SDK (Windows) , go to Settings and check "Force https:// ... sources to be fetched using http:// ...", then go to "Available packages" and Refresh. There should be more options available under main Repository URL... select them and Install.

Now you have some new Targets available on the "Create new Android Virtual Device (AVD)" Wizard window.

GL & HF

Monday, August 16, 2010

Sphinx extended query syntax

One advice I should give is about the syntax of query.

I your text-search involves more than one attribute, then you have two choices to build your query like:
1. Query: @attr1 "*keyword*" | @attr2 "*keyword*" | @attr3 "*keyword*"
2. Query: @(attr1|attr2|attr3) "*keyword*"

Now benchmarking:
1st Query, on 1000 iterations, took 23.2s of pure sphinx time
2nd Query, on 1000 iterations, took 16.2s of pure sphinx time.

Make you conclusions... ;)

PS: I also tried 3rd approach:
I made concatenated attribute, named it @attr1_attr2_attr3 in sphinx's configuration file, and query's format was like:
@attr1_attr2_attr3 "*keyword*"... 1000 iterations of this type of query, took 17.9 seconds... much better than 1st one, but still 2nd is better.

Wednesday, August 11, 2010

Bromine first install. Fatal error

I love those tricky moments, when you have to dance with a tambourine around your pc, to make it work using our galaxy logic etc.

So, the problem: I got following error when first started, freshly unzipped bromine project:


Notice: Trying to get property of non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

Fatal error: Call to a member function cd() on a non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

It's under FreeBSD (that should be important moment I guess).

You wanna know how this SHOULD be fixed?
Here is what I've found:

Go to www/app/config/core.php's line stating:
date_default_timezone_set('UTC');
and uncomment it.

Cake engine does not like when this line is commented out and acts unpredictably

IE8 dynamically created tables

I had to generate tables and append them to DOM dynamically (on ajax data requests responded).

IE8 acted as a bad-ass teacher to me, cuz I forgot to use tbody tag. So hopefully that helps:

BAD code:
var table = document.createElement("table");
var tr = document.createElement("tr");
table.appendChild(tr);
...
document.appendChild(table);

GOOD code:
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr = document.createElement("tr");
tbody.appendChild(tr);
table.appendChild(tbody);
...
document.appendChild(table);

Otherwise IE ignores the content of your table and shows it with zero height and zero width.

I should mention, that IE8's Developer Tools did help me to find that out ;)

Niivisi