Saturday, October 18, 2014

Keeping open to love

Written by Paulo Coelho

There are moments when we would like very much to help someone we love deeply and we just can't seem to do a thing. Either circumstances prevent us from drawing closer or else the person has shut off to any gesture of solidarity and support.

So, all we have left is love. In those moments when everything is useless, we can still love – without expecting anything in return, any exchanges or thanks.

If we can manage to act in this way, the energy of love begins to transform the universe around us. When this energy appears, you always perform your work successfully.

"Time does not change men. Will power does not change men. Love changes men," says Henry Drummond.

I read in the newspaper about a child in Brasília who was brutally beaten by his parents. As a result, she lost her body movements and her power of speech.

Admitted to the Base Hospital, she was taken care of by a nurse who said to her every day: "I love you." Although the doctors guaranteed that she could not hear and that the nurse's efforts were all to no avail, she kept repeating: "I love you, don't you forget that."

Three weeks later on, the child had recovered her movements. Four weeks later, she started to talk and smile again. The nurse never gave any interviews and the newspapers did not publish her name – but let it be registered here, so that we will never forget: love is a great healer.

Love transforms, love heals. But at times love builds mortal traps and ends up destroying the person who has decided to surrender completely. What strange sentiment is this that deep down is the only reason for us to go on living and struggling and trying to make things better?

It would irresponsible of me to try to define it because, like any other human being, all I can do is feel it. Thousands of books have been written about it, plays put on at the theater, films produced, poems scribbled, sculptures carved in wood or marble – and even so, all that the artist can convey is the idea of a feeling, not the feeling itself.

But I have learned that this feeling is present in the small things and manifests itself in the most insignificant of attitudes we take, so we must always have love in mind when we act or fail to act.

Picking up the phone and uttering that affectionate word we have been putting off. Opening the door and showing in someone who needs our help. Accepting a job. Leaving a job. Making that decision that we were putting off for later. Apologizing for a mistake we made that will not leave us in peace. Claiming a right that we have. Opening an account at the florist's – which is more important than the jeweler's. Playing the music loud when your loved one is far away and lower the volume when he or she is nearby. Knowing how to say "yes" and "no" – because love involves all of man's energies. Discovering a sport that can be practiced by two. Not following any prescription, not even those listed in this paragraph – because love calls for creativity.

And when none of this is possible, when all that is left is loneliness, then remember a story that a reader once sent me:

A rose dreamed day and night about having the company of the bees, but none ever came to land on her petals.

But the flower went on dreaming: during many a long night she imagined a sky with lots of bees flying towards her and kissing her tenderly. In this way she managed to resist to the next day, when she opened again to the sunlight.

One night the moon, knowing how lonely the rose felt, asked her:

– Aren't you tired of waiting?

– Perhaps. But I have to struggle on.

– Why?

– Because if I don't open up, I will wither.

At moments when loneliness seems to crush all beauty, the only way to resist is to keep yourself open.

Tuesday, October 14, 2014

Special Tuning Approach - selectively reorg the big customer's rows

For tuning the query that retrieves many rows made by big customers, it is needed some special technical approach.
Generally big customers make big rows compare to normal customers. So in using same query(SQL) there are huge differences in response time.
For example, in the ORDER_HIST table, normal customers make around 100 rows in a month whereas the big makes 10000 rows.
Response time of the normal is around 1 second whereas the big 100 seconds above.
In this case we can tune the query simply by reorganizing the rows of that big customers - that just delete and reinsert the rows.
The attached script is made for this special tuning remedy.
The effect of the result is depends on how the rows had widely dispersed before migrated.
If the rows now were much more clustered than before, then the effects will be amazing thanks to better clustering factor of now.



=============
 SCRIPT
=============
--for not stopping the service we should use 'for update' clause.
--for preventing Tx. Row Lock contention I bond every 1000 rows in one transaction rather than execute whole rows in a commit.
  If still occur Tx. Row Lock contention then lower the value from 1000 to ig. 100.

--in a SQL*Plus session

set serveroutput on

declare
  v_exe_unit_rows number := 1000; --rows per one Tx.
  v_tot_rows number      := 0;    --target rows to be reorged
  v_reorged_rows number  := 0;    --completed rows reorged
  v_commit_cnt number    := 0;    --count of commits
  
begin

  --target rows to be reorged
  select count(*)
  into v_tot_rows
  from   ORDER_HIST t
  where  acnt_num = 1111111111 --target customer
  ;
  
  for i in 1..trunc(v_tot_rows / v_exe_unit_rows)+1 loop
   
    if v_tot_rows > v_reorged_rows then
    
        for rec in ( --You should adopt sub-query for using 'for update' in Paging query
                    select t.rowid as rid, t.*
                    from ORDER_HIST t
                    where rowid in (
                                    select rid
                                    from (
                                            select /*+index(t N_ORDER_HIST_ACNT_NUM) */
                                                   t.rowid as rid
                                                 , rownum as rn
                                            from   ORDER_HIST t
                                            where  acnt_num = 1111111111 --target customer
                                            and rownum <= (i * v_exe_unit_rows)
                                            ) 
                                    where rn >= (i - 1) * v_exe_unit_rows + 1
                                    )
                    for update
                    ) loop

        --delete first
        delete ORDER_HIST
        where rowid = rec.rid;
        
        --insert later
        insert into ORDER_HIST values (
               rec.ACNT_NUM                 ,
               rec.PROD_NUM                 ,
               rec.CUST_NUM                 ,
               rec.ORDER_DTM                ,
               .
               .
               );
          
          v_reorged_rows := v_reorged_rows + 1;
          
        end loop;
        
        commit; --by 1000 rows
        v_commit_cnt := v_commit_cnt + 1;
     
    end if;
     
  end loop;     

  dbms_output.put_line('Total Rows    : ' || v_tot_rows );
  dbms_output.put_line('Reorged Rows  : ' || v_reorged_rows );
  dbms_output.put_line('commit  count : ' || v_commit_cnt );

exception
  when others then raise;
end;
/

Saturday, October 11, 2014

The two jewels

Written by Paulo Coelho

A deeply religious Rabbi lived happily with his family, an admirable woman and two dear sons. One time, he had to be away from home for several days due to work. When he was away, a serious car accident killed his two boys.

Alone, the mother suffered in silence. But being a strong woman, backed up by her faith and trust in God, she endured the shock with dignity and bravery. However, she constantly worried how she was going to break this sad news to her husband. Even though he was a man of faith, he had already been admitted to the hospital for cardiac problems in the past and his wife feared that learning about the tragedy would kill him too.

On the eve of her husband's arrival, she prayed earnestly and was given the grace of an answer.

On the following day, the Rabbi returned home, embraced his wife warmly and asked for their sons.
His wife told him not to worry about that, he should take a shower and rest.

Hours later, both of them sat down to have lunch.
She asked him for details about his journey, he told her about everything he had experienced, spoke of God's mercy, but asked about the boys again.

His wife, in a quiet embarrassed posture, answered her husband, "Leave them alone, we'll worry about them later. First I want you to help me solve a problem I consider serious."

Her husband, already worried, asked, "What happened? I noticed you are worn! Tell me everything that goes through your soul and I am sure we will solve any problem together, with the help of God."

"While you were away, a friend of ours visited me and left two jewels of incalculable worth for us to save. Those are very precious jewels! I have never seen something so stunning! He is coming to get them back and I don't want to give them back to him as I have already taken a liking to them. What do you say?"

"Well now, woman! I don't understand you! Vanities have never appealed to you!"
"It is that I had never seen such jewels! I can't accept the idea of losing them forever!"

And the Rabbi answered:
"No one loses what he doesn't own. Keeping them would be like stealing! We are going to return them and I will help you get over them. We will do that together, today."

"Very well, my dear, as you wish. The treasure will be returned. In truth, that has already been done. The precious jewels were our sons. God trusted us their guard and during your trip he came to get them. They are gone…"

The Rabbi embraced his wife, and together they shed many tears, but he had understood the message and from that day on they fought to overcome the loss together.