วันศุกร์ที่ 15 เมษายน พ.ศ. 2554

py4j กับ mondrian

เนื่องจากส่วนตัวไม่ค่อยอยากหัดเขียน java ดังนั้นเวลาใช้งาน mondrian จึงเกิดปัญหามากมาย แต่พออ่านอันนี้แล้ว สำหรับสาวก python ก็สามารถใช้ python เรียก mondrian ได้เหมือนกันแฮะ

http://stackoverflow.com/questions/3793215/query-olap-mondrian-mdx-xmla-with-python-interface

วันอังคารที่ 12 เมษายน พ.ศ. 2554

คิดแบบเบ็ดเสร็จ ย้อนกลับมาหาวิธีการและแหล่งที่มา

วันนี้เป็นอีกวันที่ต้องปวดหัวกับคำถามที่อยู่ ๆ ก็โยนข้อมูลดิบและสิ่งที่ต้องการมาให้

ข้อมูลดิบเป็นข้อมูลที่ได้มาจากระบบ Point Of Sales แต่สิ่งที่อยากได้คือการวิเคราะห์ที่ได้จากข้อมูลนั้น วิธีการที่ดูแล้วจะช่วยให้หยิบข้อมูลในแต่ละมุม (dimension) มาเปรียบเทียบและหาคำตอบที่ต้องการก็คงไม่พ้นการใช้ Cube เพราะข้อมูลมันมีจำนวนมหาศาล

ลองนึก ๆ ดูแล้วที่เค้าเรียกว่าวงจรการวิเคราะห์​ (Cycle of Analysis) น่าจะจริง


  1. ลองนำข้อมูลที่ได้มาทำเป็น Data Warehouse
  2. แล้วเลือกชุดข้อมูลที่ต้องการมาทำ Cube
  3. ผลที่ได้จาก Cube จะบอกว่าเราจะทำอะไรต่อ
  4. แล้วก็กลับไปทำของ 2 อีกครั้ง 

แต่ก็เหมือนมันเป็นการแก้ปัญหาที่ปลายทางมาก ลองนึกใหม่ว่าทำอย่างนี้ได้หรือไม่
  1. ถามตัวเองว่าเมื่อทำระบบแล้วมันจะได้ข้อมูลอะไรบ้าง
  2. เมื่อได้ข้อมูลนั้น ๆ แล้วจะทำอย่างไร
  3. แล้วก็ออกแบบวิธีการที่จะได้มาซึ่งข้อมูล
  4. พัฒนาระบบ

วันจันทร์ที่ 4 เมษายน พ.ศ. 2554

Memory พอไหม

มาดูกันว่าค้นนี้เค้าตอบว่าอย่างไรบ้าง


> Mem:  16299476k total, 16198784k used,   100692k free,    73776k buffers
> Swap: 16787884k total,   148176k used, 16639708k free, 15585396k cached
>
>  PID   USER      PR  NI  VIRT    RES   SHR   S    %CPU  %MEM    TIME+    COMMAND
>  3401 postgres   20   0   4288m  3.3g    3.3g   S     0         21.1         0:24.73   postgres
>  3397 postgres   20   0   4286m  119m  119m  S     0        0.8           0:00.36   postgres


> PLease help me to understand how much memory does 1 Connection Uses and how
> to use Server parameters accordingly.

OK, first, see the 15585396k cached?  That's how much memory your OS
is using to cache file systems etc.  Basically that's memory not being
used by anything else right now, so the OS borrows it and uses it for
caching.

Next, VIRT is how much memory your process would need to load every
lib it might need but may not be using now, plus all the shared memory
it might need, plus it's own space etc.  It's not memory in use, it's
memory that might under the worst circumstances, be used by that one
process.  RES is the amount of memory the process IS actually
touching, including shared memory that other processes may be sharing.
 Finally, SHR is the amount of shared memory the process is touching.
so, taking your biggest process, it is linked to enough libraries and
shared memory and it's own private memory to add up to 4288Meg.  It is
currently actually touching 3.3G.  Of that 3.3G it is touching 3.3G is
shared with other processes.  So, the difference between RES and SHR
is 0, so the delta, or extra memory it's using besides shared memory
is ZERO (or very close to it, probably dozens or fewer of megabytes).

So, you're NOT running out of memory.  Remember when I mentioned
iostat, vmstat, etc up above?  Have you run any of those?





เดี๋ยวมารอดู iostat กันต่อ