Wednesday, June 11, 2008

MySQL Index varchar fields partially

Once upon a time :) I had a simple table.
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| pnrkey | bigint(20) unsigned | NO | MUL | NULL | |
| pr_aac | char(2) | NO | MUL | NULL | |
| pr_pn_fn | varchar(99) | NO | MUL | NULL | |
| pr_pn_ln | varchar(99) | NO | MUL | NULL | |
+----------+---------------------+------+-----+---------+-------+
I created it using the following create statement..
DROP TABLE IF EXISTS ePDI_passengername;
CREATE TABLE ePDI_passengername (

pnrkey BIGINT UNSIGNED NOT NULL,
pr_aac CHAR(2) NOT NULL,
pr_pn_fn VARCHAR(99) NOT NULL,
pr_pn_ln VARCHAR(99) NOT NULL,

INDEX ePDI_passangername_index_pr_fn(pr_pn_fn),
INDEX ePDI_passangername_index_pr_aac(pr_aac),
INDEX ePDI_segmentData_index_pnrkey(pnrkey),
INDEX ePDI_passengername_index_pn_ln(pr_pn_ln)

)PARTITION BY RANGE(pnrkey)(
PARTITION p0802 VALUES LESS THAN (2008030000001),
PARTITION p0803 VALUES LESS THAN (2008040000001),
PARTITION p0804 VALUES LESS THAN (2008050000001)
);

I added 500,000 records to my table, and saw that the index table MYI was bigger in size than the data one MYD. also I was not happy with the performance of indexes on pr_pn_fn & pr_pn_ln as mysql ignored indexes in like '%string%' kind of searches and the performance was very poor in like 'string%' kind of searches

I shortened the indexes and found improvement in performance

Altering table indexes
alter table ePDI_passengername drop Index ePDI_passangername_index_pr_fn;
alter table ePDI_passengername add Index ePDI_passangername_index_pr_fn(pr_pn_fn(10));

Database interview questions

  1. What is the difference between a primary key and a unique key.
  2. How do I find all the people whose salary are the third highest in an organization.
  3. Why do we partition tables
  4. What is the difference between Inner join and outer join.

Saturday, June 7, 2008

Eclipse security component error in Ubuntu

If you get this error "Could not initialize the application security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restrictions and your hard disk is not full or close to full. It is recommended that you exit the application and fix the problem. If you continue to use this session, you might see incorrect application behaviour when accessing security features"
try this
mkdir ~/.mozilla/eclipse
chmod 777 ~/.mozilla/eclipse

Tuesday, May 27, 2008

Java interview questions

  1. What are the various ways to implement threads.
  2. How do we make a section of code thread-safe.
  3. What all do you know about Springs Framework.
  4. Which template have you used in Springs DAO.
  5. Explain some features of Hibernate.
  6. How is Hibernate different that Springs DAO.
  7. Which version of Struts have you worked on.
  8. Explain the flow of control in a struts framework.

Thursday, May 22, 2008

AverTV Super 007 on Linux ( Ubuntu )

I recently purchased this tuner card was disappointed to discover that it was not running on Ubuntu 8.04, I read forums and was happy to know that it was not impossible, but the issue was that a lot of stuff was written, I have filtered out to few steps that helped me to get the card working
  1. sudo apt-get install mercurial
  2. hg clone http://linuxtv.org/hg/v4l-dvb
  3. cd v4l-dvb
  4. sudo make
  5. sudo make load
Start tvtime and things should work.

PHP, MySQL Interview questions

  1. What are the differences between PHP4 & PHP 5.
  2. Give your ideas how you can scale up a LAMP based website.
  3. Which design pattern is used by Symfony.
  4. what is the difference between pass by value and pass by reference.
  5. Describe the highlights of MVC architecture.
  6. How many types of tables does MySQL have.
  7. What are the differences between MyIASM and INNODB table types.
  8. What could be a possible reason if someone is looking to store session information inside a database, what are the steps involved in doing the same.
  9. How would you do clustering in MySQL.
  10. What are the different types of Indexes in MySQL.
  11. Explain FullText index in MySQL.
  12. Can we overwrite a row using insert in MySQL if the primary key is unique.
  13. Suggest some optimization steps in MySQL and sql queries.
  14. How would you create a function which would accept variable number of inputs.

Thursday, May 8, 2008

Postgres showprocesslist

Looking for something like showporcesslist for postgres, here is something I found.
Edit your postgres.conf
stats_start_collector = true

This must be set to true for the statistics collector to be launched at all.

stats_command_string = true

This enables monitoring of the current command being executed by any server process. The statistics collector subprocess need not be running to enable this feature.


After restarting postgres the following query will show currently running queries


psql -U postgres template1 -c "select * from pg_stat_activity"

only as user "postgres"