2012-08-05

Amazon got recommendations for me

A few weeks ago I happened to hear a cool recording of Baby please don’t go  by Muddy Waters and The Rolling Stones   http://www.youtube.com/watch?v=Mbao_laqF8E

Inspired by the music I spent some  hours listening to these guys and others favourites like Lightnin’ Hopkins and Champion Jack Dupree mostly via YouTube.

Then this week I got recommendations from Amazon:

Wow, CJD isn’t the most popular artist these days, Amazon must have found my interest in CJD via me looking for him on Youtube . (I’m pretty sure I have not searched for CJD on Amazon. I also wrote a mail where I mention CJD, but Amazon hopefully do not scan my mails that would be a step too far :-)

Anyway this recommendation probably comes from  some Business Intelligence activity.Of course I was curious how Amazon found out of my interest in CJD, so I sent a query to Amazon:

08/01/12 22:19:46

Your Name: Lars Johansson

Comments: I'm curious about your recommendation to buy CD's by Champion Jack Dupree.<p></p>I would appreciate an explanation of the process resulting in you recommending me to buy Champion Jack Dupree CDs.

And I got this response:

Hello,

I'm sorry to hear you're unhappy with some of the products that were recommended for you on Amazon. To prevent certain purchases from affecting your recommendations, please follow the instructions here:

http://www.amazon.com/gp/help/customer/display.html?nodeId=13316081#improving

To prevent certain items you've viewed recently from affecting your recommendations, please follow the instructions here:

http://www.amazon.com/gp/help/customer/display.html?nodeId=13316081#yourbrowsing

If you don't want to see our recommendations, you can log out of your Amazon.com account by moving your cursor to the "Your Account" menu at the top of the home page and selecting "Sign Out" from the expanded list of options. On the next page, leave the e-mail and password spaces blank and click the Amazon.com logo. Your recommendations won't appear on the website until the next time you sign into your Amazon.com account.

I hope this helps! We look forward to seeing you again soon.

Thank you for your inquiry. Did I solve your problem?

If yes, please click here:

http://www.amazon.com/gp/help/survey?p=A3BEERLL87AJC2&k=hy

If no, please click here:

http://www.amazon.com/gp/help/survey?p=A3BEERLL87AJC2&k=hn

 

But I was not unhappy  about the recommendation, I was curious how they found my interest for CJD, so I once again asked Amazon how they did. I’m still waiting for Amazon’s reply.


Working with Business Intelligence I have analyzed our customers behavior to come up with Sales Leads. I’m not using some sophisticated web scanner, I only try to analyze existing customers purchases e.g. have the customer bought spare parts but no service? When did they buy our products? Have they bought the new model? etc. But we have plans to be more active and come up with better Sales Leads and targeted advertisements using our Sales and Marketing statistics.

Many years ago I worked as a DBA, administering the Sales database of a TV-shop. I got complaints from the TV-shop, that the database was down early Sunday mornings. I took down the database for housekeeping like reorg etc. Sunday morning 04.00, and the database was down for an hour. To my surprise I was told there are many (lonely?) drunkards buying like crazy the night between Saturday and Sunday, this was a respectable TV-shop selling normal TV-shop merchandise . So I had to reschedule the jobs to the night after between Sunday to Monday, which was a low activity night.

P.s.

If Amazon’s recommendation had come the night while I was listening to CJD I would probably had bought some music. Business Intelligence is very much a question of speed. The analysts need the reports now, not tomorrow.

2012-07-24

My summer of code - 2

Just south of Sète, France

Each summer vacation if I do not have anything better to do, I try study a subject in some detail, something I can use in my daily  work. I wrote a post about   my Summer of Code . This year I decided to study computer language  ‘D’ , but unfortunately I found better things to do. A summer vacation which I have blogged about   here ,   here  and   here . Back at the office I had to clean up the mess I thought I had created during the vacation, fortunately this time  I was not to blame . Then I have to replace some   hardware  and create a   data warehouse for Fuji Air Tools factory .  

I also have to do some web programming, we may need an Excel sheet like  grid application with the capability to communicate bi-directionally with SAP. If you have followed my blogging you know I’m not a good  experienced web programmer. I have with the help of my friend Andreas  decided to learn the   Sencha/ExtJS  framework to jumpstart my web capabilities.

Up in the mountains, Axel and Erik. Down behind is a pit hundreds of meters deep.

So much for my Summer of Code 2012. I have to postpone ‘D’. When I have time for ‘D’ then I probably will choose   Perl6 , it looks like Perl6 begins to be ready for production in some not too distant future. At the moment I doubt I will have time for Sencha/ExtJS, but we’ll see.

I pray next year I have time for ‘D’ and Perl6, or better the year after. I like to go down to France next year again. I’m beginning to be a francophile like my son Axel. This country has it all from skiing to beach life. And so much more. I have some colleagues in Nantes, maybe I should ask if they have some work for me.

2012-07-21

Aftermath of vacation

During   my vacation , our Business intelligence system was hit by two severe crashes, the first one   currency rate load failure  I have blogged about, but we also had failed to load project costs from SAP. Two days before my vacation I enhanced the   job iterator  functionality in my job scheduling system.  While trying to debug the currency rate problem on the German Autobahn on my way to France, I got a call from the office telling me there is also a problem with project costs. From the info I got I guessed it must have something to do with job iterators, the costs where to high 17 times to be exact. And the job that failed had a job iterator with 17 rows. I could not for my life figure out what the problem was and I had done extensive testing of my changes, but  if you finds bugs look at the last changes and 17 was also pointing  at my job iterator, so still on the road I backed out my changes, but the cost problem remained.
Back at the office we found out  the problem had started before I made the changes, it was another job that was the culprit and not all projects were affected. Since all updates are done with SQL we suspected unwanted duplicate rows in some involved table. During my absence two colleagues had analyzed the problem and they had isolated the problem to SAP table EKPO (purchasing document items). So we checked our ‘copy’ of the EKPO table and found no indexes. EBELN (Purchasing Document) and EBELP (PD item) should be primary index in our EKPO table. By the query select count(*),EBELN, EBELP from EKPO group by EBELN, EBELP having count(*) > 1 , we found SEVENTEEN  invalid rows with blank EBELN, EBELP (these rows were inserted into SAP a few days before my vacation). We removed the offending lines, inserted the primary index and reloaded the costs, now right again to the last cent.
This crash could have been avoided if we have had proper input checks and correct indexes on the database table but we do make mistakes, ‘those who do not do mistakes tend not to do anything at all’. And as always, shit happens at the worst possible time. Murphy rules.
   
One interesting observation, the execution time for the failing SQL increased from 2 minutes to over 8 hours with these 17 bad EKPO rows! I end this post with the failing SQL.
 
INSERT INTO WBS_TABLEB_temp1  (
                            SELECT
                            'WBS', '1', A.PSPID, A.POST1, B.POSID, C.PERIO,
                            CASE
WHEN LEFT(CONCAT(substring(B.POSID,9),' ','/',B.POST1),2) = ' /' THEN 'Internal Order & Unassigned'
WHEN LEFT(CONCAT(substring(B.POSID,9),' ','/',B.POST1),5) IN ('03-01','03-02') THEN CONCAT(substring(B.POSID,9),' ','/',B.POST1,' ','Lab')
                                   ELSE CONCAT(substring(B.POSID,9),' ','/',B.POST1)
                            END AS SufixName,
                            CAST(I.COST_ELEMENT AS SIGNED),
                            COALESCE(I.DESCR_LONG, C.KSTAR, 'NO NUMBER EXISTS') AS AccountDescription,
                            C.WOGBTR,  C.MATNR,
                            COALESCE(E.MAKTX, C.MATNR, 'NO NUMBER EXISTS') AS MATDESCR,
                            C.EBELN,
                            COALESCE(F.TXZ01, C.EBELN, 'NO NUMBER EXISTS') AS PurchOrderText,
                            COALESCE(H.SNAME, C.PERNR, 'NO NUMBER EXISTS') AS Person,
                            C.PERNR, C.MBGBTR, C.MEINH, A.PRCTR, C.FKBER,
                            CONCAT(RIGHT(CAST(C.GJAHR AS CHAR),2),LPAD(CAST(C.Perio AS CHAR), 2, '0')) AS Period,
                            C.BUKRS, B.PSPNR, C.GJAHR, B.FKSTL, C.REFBN, C.BUDAT, A.VERNA, A.ASTNA, A.PROFL,
                            COALESCE(L.TypeDescr, L.TypeNr, 'NO NUMBER EXISTS') AS ProfileDescr,
                            B.USR00, C.PAROB, C.PAROB1, C.USPOB, I.CON_AREA,
                            I.SETNAME AS SetName, I.SUBSETNAME as SubSetName,
                            I.SUBSETDESCR as AccountGroup,I.DESCR_LONG AS AccountConcat,
                            C.PAROB, C.CPUDT, C.BLDAT, C.BLTXT, C.BELNR, C.BLART, C.SGTXT,C.GKONT, C.USNAM,
                            C.WSDAT,C.PFKBER, C.PSCOPE,C.WERKS,C.BUDAT, C.AWTYP,C.AWREF_REV,
                            C.CPUTM,M.CRI,M.DOC_ID, H.KOSTL,
                            CASE   WHEN C.REFBN IS NULL OR M.CRI IS NULL OR M.REF_DOC_NR IS NULL
                                   THEN 'No' ELSE 'Yes'
                            END AS PDF_Document
                            FROM ACTAPRJ.PROJ A
                            RIGHT JOIN ACTAPRJ.PRPS B
                            ON A.PSPNR = B.PSPHI
                            LEFT JOIN ACTAPRJ.COVP C
                            ON B.OBJNR = C.OBJNR
                            LEFT JOIN ACTAPRJ.CSKU D
                            ON C.KSTAR = D.KSTAR
                            AND D.SPRAS ='E'
                            LEFT JOIN ACTAPRJ.MAKT E
                                ON C.MATNR = E.MATNR
                            LEFT JOIN ACTAPRJ.EKPO F
                            ON C.EBELN = F.EBELN
                            AND C.EBELP = F.EBELP
                            LEFT JOIN ACTAPRJ.PA0001 H
                            ON C.PERNR = H.PERNR
                            AND H.ENDDA > NOW()
                            LEFT JOIN ACTAPRJ.DB3FTM_SET_STRUCTURE_PS I
                            ON C.KSTAR = I.COST_ELEMENT
                            LEFT JOIN ACTAPRJ.PROJECT_TYPE L
                            ON RIGHT(A.PROFL,2) = L.ID
                            LEFT JOIN ACTADW.DB3FTM_EXTERNAL M
                            ON C.REFBN = M.REF_DOC_NR
                            AND M.REF_DOC_NR <> ''
                            WHERE C.KSTAR NOT IN ('9999210000','9999210003','9999210004','0009004902')
                            )
                            UNION ALL
                            ( SELECT
                            'IO', '1', A.PSPID, A.POST1,
                            COALESCE(RIGHT(E.AUFNR,10), E.PSPEL, 'NO NUMBER EXISTS') AS OBJECT,
                            C.PERIO,
                            CASE
WHEN LEFT(CONCAT(substring(B.POSID,9),' ','/',B.POST1),2) = ' /' THEN 'Internal Order & Unassigned'
                                           ELSE CONCAT(substring(B.POSID,9),' ','/',B.POST1)
                            END AS SufixName,
                            CAST(I.COST_ELEMENT AS SIGNED),
                            COALESCE(I.DESCR_LONG, C.KSTAR, 'NO NUMBER EXISTS') AS AccountDescription,
                            C.WOGBTR, C.MATNR,
                            COALESCE(K.MAKTX, C.MATNR, 'NO NUMBER EXISTS') AS MATDESCR,
                            C.EBELN,
                            COALESCE(F.TXZ01, C.EBELN, 'NO NUMBER EXISTS') AS PurchOrderText,
                            COALESCE(H.SNAME, C.PERNR, 'NO NUMBER EXISTS') AS Person,
                            C.PERNR, C.MBGBTR,C.MEINH, A.PRCTR, C.FKBER,
                            CONCAT(RIGHT(CAST(C.GJAHR AS CHAR),2),LPAD(CAST(C.Perio AS CHAR), 2, '0')) AS Period,
                            C.BUKRS,B.PSPNR,C.GJAHR,B.FKSTL,C.REFBN,C.BUDAT, A.VERNA, A.ASTNA, A.PROFL,
                            COALESCE(L.TypeDescr, L.TypeNr, 'NO NUMBER EXISTS') AS ProfileDescr,
                            B.USR00,C.PAROB,C.PAROB1,C.USPOB, I.CON_AREA,
                            I.SETNAME AS SetName,I.SUBSETNAME as SubSetName,
                            I.SUBSETDESCR as AccountGroup,I.DESCR_LONG AS AccountConcat,
                            C.PAROB, C.CPUDT,C.BLDAT,C.BLTXT,C.BELNR, C.BLART, C.SGTXT, C.GKONT,
                            C.USNAM, C.WSDAT,C.PFKBER, C.PSCOPE,C.WERKS,C.BUDAT, C.AWTYP,
                            C.AWREF_REV, C.CPUTM, M.CRI,M.DOC_ID,H.KOSTL,
                            CASE
                                     WHEN C.REFBN IS NULL OR M.CRI IS NULL OR M.REF_DOC_NR IS NULL
                                     THEN 'No' ELSE 'Yes'
                            END AS PDF_Document
                            FROM ACTAPRJ.PROJ A
                            RIGHT JOIN ACTAPRJ.PRPS B
                            ON A.PSPNR = B.PSPHI
                            RIGHT JOIN ACTAPRJ.AUFK E
                            ON B.PSPNR = E.PSPEL
                            RIGHT JOIN ACTAPRJ.COVP C
                            ON E.OBJNR = C.OBJNR
                            LEFT JOIN ACTAPRJ.CSKU D
                            ON C.KSTAR = D.KSTAR
                            AND D.SPRAS ='E'
                            LEFT JOIN ACTAPRJ.MAKT K
                            ON C.MATNR = K.MATNR
                            LEFT JOIN ACTAPRJ.EKPO F
                            ON C.EBELN = F.EBELN
                            AND C.EBELP = F.EBELP
                            LEFT JOIN ACTAPRJ.PA0001 H
                            ON C.PERNR = H.PERNR
                            AND H.ENDDA > NOW()
                            LEFT JOIN ACTAPRJ.DB3FTM_SET_STRUCTURE_PS I
                            ON C.KSTAR = I.COST_ELEMENT
                            LEFT JOIN ACTAPRJ.PROJECT_TYPE L
                            ON RIGHT(A.PROFL,2) = L.ID
                            LEFT JOIN ACTADW.DB3FTM_EXTERNAL M
                            ON C.REFBN = M.REF_DOC_NR
                            AND M.REF_DOC_NR <> ''
                            WHERE C.KSTAR NOT IN ('9999210000','9999210003','9999210004','0009004902') AND
.PSPID != ' ‘ );

2012-07-17

Annoying statistics

I have been looking at my blog statistics and found a most annoying thing. In my series Job Scheduling with PHP  almost no one  reads  the last and most interesting post Job Scheduling with PHP - 4. The obvious interpretation is you my dear reader do not find the first three parts interesting enough to read the final post. In future I have to improve my writing or write about more interesting stuff. But that is what my blogging exercise is about learn to be a better blogger.

Family blogging


Some days ago I learned I’m not the only one in the family with a blog,  I got a blogging niece Julia. My son told me I figured in a post as ‘her senile uncle that knows it all’. I tried to resist the temptation to look but this morning I tried to find the post. I could not find that post but I found another interesting post, she mention she is hours too early at airports, as there always something going wrong when she or her mother is flying. She thinks this is in her genes. Read the last paragraph of this post. It’s in the family genome. I’m a bit surprised as her mother (my sister) is a well-structured headmaster, I always thought my airport problems  was due to I’m a bit offhand and absent-minded. It feels better knowing it’s in the genes, there is nothing I can do about it.

As Julia’s uncle I have to comment her blog. It is not what I expected. Is this really my niece who graduated from college with absolute top scores? I knew she works as a part time paparazzi and likes to party. But this looks more than part time. And when is she going to start studying at KTH? I’m sure Julia will do fine in future too, she is not only smart, she is also very tough and competitive.

 I suspect Julia is a more successful blogger than I am. I thought I had 1000 visits a week ago but that was not so, I have had 1000 page views since the start. Julia probably have more page views in a day. At next family gathering I should ask her for advice, how to make my blog more attractive.

2012-07-16

Always online

Always online is a reality, we were four people on the road with two cellphones, two smartphones, two Ipads, three PC notebooks, one 3G modem, one Apple notebook and an Amazon Kindle. We had constant access to the Internet, friends and work during the entire trip. All of us liked it, (for those who do not like this new connected lifestyle there is an off-button on all devices). Being hooked up to the web simplifies a lot of things when you are on vacation like ordering car spare parts or finding hotel for the night along the way.
In 1995 I was together with six others on a boat outside Stockholm all with cellphones at that time we realized in future everyone would have a cellphone and be accessible 24X7. But that four people on a vacation  road trip 2012 should have two cell phones, five Internet connected devices plus a tracking device with a complete European map and some extra computers, was beyond our imagination.
I’m home again after an unusual  vacation. A road trip together with my two sons and the oldest son’s girlfriend, for two weeks it’s sounds like a recipe for a   Norén  family drama.(As you may deduct from the picture of Norén he is not in for comedy, actually I do not like his public image or his plays.) But the four of us got along just fine. I only flipped out once or twice driving in towns. I hate driving in towns I do not know, my sense of directions is not bad, it’s nil . (According to my sons, my world is a Rubrik’s cube constantly twisting.) We had bought a GPS navigator, Navigon 72 Easy  for this trip, this little wonder box proved to be invaluable to find the way in Central Europe, but it had its flaws, it hung when needed the most inside towns, and it sometimes points out odd routes in towns, but on the whole it was great guide. But had I known what I know now, I had spent another 100€ on a better more online navigator.  This navigator has a peculiar habit of jumping between roads, e.g. I had been northbound on Autobahn A1 for some 50 km when the navigator  jump over to a parallel country road and suggested I should make a U turn if possible. During this trip I have been following   Carl Mäsak’s  posts on making an adventure game in Perl6 , there you are only allowed to walk between rooms if there is a crossing, this logic is missing in my navigator.
It took us four days to reach our final destination Gignac in France. On the way south we stopped in København in Denmark,  Dijon and Montpellier in France, three very nice towns you should visit if you have the chance. We hit the Hamburg evening rush hours and that is something you should avoid, apart from that the trip went smoothly. We had to change a wheel bearing in Malmö. Just outside Stockholm we noticed a malicious sound from left the rear wheel,  it had to be the wheel bearing so we called a   garage in Malmö  and asked them to be prepared to replace the bearing when we arrived there. While we had lunch they repaired the car and an hour later we drove on to France. My car a Volvo V50 performed great, in Germany we found out 170km/h was optimum cruising speed. With modern IT gear you can do a lot. With some Ipads and smartphones it was easy to find a garage and without even slowing down arrange a repair. Later during the trip we reserved hotel rooms via hotels.com using the same IT gear. I also invented   speed-debugging  with my PC and a 3G modem while my son tested optimal cruising speed. We had a very pleasant stay in Gignac . The landscape up in the mountains is breathtaking, and the Mediterranean beaches south of Sète  are fantastic. Not to mention the food and wine, we loaded the car with bottles from the wine cellar of   Dumas Gassac .
We took the return trip in two legs. First to Köln in Germany and then home. We stayed for three nights in Köln, a very nice City, for those of you who have not seen the Cathedral the   Kölner Dom  I can tell you it’s stunningly huge and beautiful. We visited some great art museums contemporary and old/ancient. We spent a fortune on shopping.  The youngsters had one great night on the town, they came back to the hotel at about 05:00. The second leg Köln-Stockholm was done in only fourteen hours. And tomorrow I be back at the office .
On next year's summer vacation I will only have one 4G smartphone and my Kindle. Electronic Ink  screens are superior to LED screens, I’m eagerly waiting for Color Electronic Ink screens in other pads, PC and phones. Today we can replace the PC with pads and smartphones, but for reading books we need better screens than LED, Electronic Inc or similar techniques are the next screen evolution. Something that emulate paper!  

2012-07-10

Business Intelligence and Hardware

Hardware is often neglected in applications design.  In best cases you divide components of an application into separate servers, move the data to a separate SAN and add some extra RAM for performance and that’s it. The server infrastructure of applications is often well suited for transactional systems. Transactional systems do lot of random read/write of small chunks of data and very little processing on those small chunks.Business Intelligence systems on the other hand does not write very much, but reads a lot. Both reads and writes are mostly done in large chunks.  

 

Since the middle of the nineties I have been interested in BI applications hardware infrastructure. My interest for hardware started with the   spintronic  revolution, I realized that hard disks (HDD) and memory RAM was going to be larger, faster and cheaper in future. HDD was the first in the spintronic wave. HDD had been too small, too slow and too expensive to allow for modern BI; with the SATA HDD we had cheap, fast and large HDD. The seek time (find the data to read or write) on these cheap SATA HDD is not impressive, so if you need to do lots of small random read/write it is not a wise choice. So the traditional servers still use expensive and small HDD with good seek time.  These HDD are not very good for BI. BI are more interested in low transfer time (from disc into memory) than low seek time, and the SATA protocol can deliver more data than the discs can spin. More important SATA disks today are large, you can get 3 TB SATA disks for about 200€ and size matters for BI operations.  SATA HDD are better suited for BI than more expensive and smaller HDD  found in servers. Of course we will use Solid State Disks in a few years’ time, but still these disks are too expensive and too small for my liking .

Lots of RAM more than compensate for the slower  SATA disks (compared with SAS and SSD),  today you get 24GB SSD3 for about 300€. It is important to have enough of RAM to keep the active data set in memory to keep physical I/O low. Our BI database server needs 16GB to perform well. First day of the month I have noticed increased response times and some ‘peculiar’ MySQL behavior. I will install more memory and see if that helps. If not I have to find the root cause for the increased response times which most likely is missing or not good enough indexes. I still see recommendation about being careful with adding indexes. For BI systems this is wrong, wrong, wrong. You should sprinkle your database with indexes. All frequent queries should have optimized indexes. For the experienced DBA I recommend   Relational Database Index Design and the Optimizers’ by Tapio Lahdenmaki and Mike Leach . This is serious, heavy and good reading about indexes. But I first try to mend performance problems with hardware, it is simpler to add RAM, than to analyze bottlenecks.

Processors today are so powerful any modern multicore processor will do just fine. I use high quality workstation motherboards. For my last database server I used an ASUS P9X79 DELUXE X79 S-2011 ATX motherboard   for about 300€. It performs beautifully for our Business Intelligence system.

With such components it is an easy task to build high performance BI servers. I build the servers as simple as possible, this means I deliberately build them as single-point-of-failure. Simple server means few things that can crash and my servers are remarkably stable. The only things that have crashed so far are HDD raids and raid controllers (two times in eight years). Today disks are so big so we do not need to raid them anymore. Hardware development goes very fast; last year’s top notch hardware is ready for the scrap heap the next year. Using inexpensive servers give me the luxury to replace them more often. The normal lifetime for a server is three years and the life time cycle is test-production-backup-scrap heap. The database server I try to replace more often.

I’m aware of most experts do not approve of my ideas. But I created a working system after these ideas and it performs beautifully. I have put lots of efforts into my system; thinking, testing, measuring. More important than hardware is the database design. I have completely removed the traditional snowflake or whatever it is called design. The traditional BI database design patterns were conceived when hardware were expensive and disks were small. With today’s cheap hardware the old design patterns are a millstone around the BI system’s neck, we will see new simpler databases with more redundancies as in-memory computing becomes a reality. I should probably post about this, since I am an humble pioneer in this field.  

This is how my ‘tin cans’ look 2012-12-23.