bigquery

bigquery

ข่าวและบทความที่เกี่ยวข้อง

All bigquery

PostType Filter En

บทความ

บริหาร BigQuery ยังไงให้คุ้ม (BigQuery Cost Optimization)  
BigQuery เป็นเครื่องมือทรงพลังสำหรับการวิเคราะห์ข้อมูลขนาดใหญ่ แต่หากใช้ไม่เป็น ค่าใช้จ่ายอาจพุ่งสูงโดยไม่รู้ตัว มาเรียนรู้เทคนิคการใช้งาน BigQuery อย่างชาญฉลาด เพื่อให้ได้ประสิทธิภาพสูงสุดในราคาที่คุ้มค่าที่สุด BigQuery คืออะไร  BigQuery คือบริการวิเคราะห์ข้อมูลแบบคลาวด์ (Cloud Data Analytics Service) ที่นำเสนอโดย Google Cloud Platform เป็นโซลูชั่นที่มีความสามารถในการประมวลผลข้อมูลในขนาดใหญ่และความเร็วสูง โดยไม่ต้องมีการจัดการกับโครงสร้างพื้นฐานเอง ทำให้ผู้ใช้สามารถโฟกัสที่การวิเคราะห์ข้อมูลได้มากขึ้น  คุณสมบัติหลักของ BigQuery  การใช้งาน  BigQuery เหมาะสำหรับการวิเคราะห์ข้อมูลในหลากหลายรูปแบบ เช่น:  BigQuery เป็นเครื่องมือที่มีประสิทธิภาพสูงสำหรับองค์กรที่ต้องการทำการวิเคราะห์ข้อมูลที่ซับซ้อนและในปริมาณมาก โดยไม่ต้องลงทุนในโครงสร้างพื้นฐานด้านไอทีที่มีค่าใช้จ่ายสูง  การคิดค่าใช้จ่าย  การคิดราคาของ BigQuery แบ่งออกเป็น 2 ส่วนหลัก: ราคาสำหรับการประมวลผล (Compute Pricing) และราคาสำหรับการจัดเก็บข้อมูล (Storage Pricing)  การประมวลผล (Compute Pricing)  BigQuery มีสองโมเดลการคิดราคาสำหรับการประมวลผล:  การจัดเก็บข้อมูล (Storage Pricing)  BigQuery มีการคิดราคาสำหรับการจัดเก็บข้อมูลสองประเภท:  โดยพื้นที่การจัดเก็บข้อมูล 10 GiB แรกจะไม่มีค่าใช้จ่าย  เทคนิคการลดค่าใช้จ่ายของ BigQuery  ปัญหาส่วนใหญ่ของราคาที่เกิดขึ้น มักจะมาจากการประมวลข้อมูลที่มีขนาดใหญ่บ่อยด้วยการคิดเงินแบบ On-Demand ทำให้ไม่สามารถควบคุมค่าใช้จ่ายที่เกิดขึ้นได้ โดยวิธีในการลดค่าใช้จ่ายนั้นก็มีหลากหลายวิธี ดังนี้  เป็นการจัดเก็บข้อมูลในฐานข้อมูลที่มีการเก็บผลลัพธ์ของการสืบค้น (query) ไว้ล่วงหน้าเป็นตารางจริง ๆ ในฐานข้อมูล ซึ่งต่างจาก standard view ที่จะดำเนินการสืบค้นใหม่ทุกครั้ง ซึ่งจะเหมาะกับการประมวลข้อมูลที่ต้องการรวมข้อมูล (aggregate) การกรองข้อมูลบางส่วน, การผสมข้อมูลกับตารางอื่น เป็นต้น โดยสามารถศึกษาเพิ่มเติมได้ที่ Link   เป็นบริการวิเคราะห์ข้อมูลที่ถูกจัดเก็บอยู่ในหน่วยความจำ (in-memory) ซึ่งจะมีการจัดเก็บข้อมูลที่ถูกใช้อยู่บ่อย ๆ ทำให้ไม่ต้องย้อนกลับไปประมวลผลข้อมูลตั้งแต่ต้น ช่วยลดการอ่านข้อมูลซ้ำ ๆ ได้เป็นอย่างดี สามารถอ่านรายละเอียดเพิ่มเติมได้ที่ Link   การคิดราคาตามความสามารถในการประมวลผล (slots) ซึ่งเป็นหน่วยวัดการประมวลผลของ CPU เสมือนจริง ซึ่งจะเหมาะกับการประมวลผลข้อมูลที่สามารถรอได้นาน หรือข้อมูลที่ถูกอ่านเพื่อประมวลผลที่มีปริมาณที่มาก โดยสามารถปรับจำนวน slot ได้ตามต้องการและสามารถตั้งค่าให้ปรับแบบอัตโนมัติตามความต้องการใช้งานของระบบได้ ทำให้สามารถคาดการค่าใช้จ่ายที่จะเกิดขึ้นสูงสุดในแต่ละเดือน สามารถอ่านรายละเอียดเพิ่มเติมได้ที่ Link โดยวิธีการนี้จะมีการให้บริการในหลายราคาตามแพคเกจซึ่งจะเปรียบในตารางด้านล่างนี้     Standard  Enterprise  Enterprise Plus  On-demand pricing  Pricing model  Slot-hours (1 minute minimum)  Slot-hours (1 minute minimum)  Slot-hours (1 minute minimum)  Pay per query with free tier  Compute model  Autoscaling  Autoscaling + Baseline  Autoscaling + Baseline  On-demand  Commitment plans  No access to capacity commitments  1-year commitment at 20% discount or 3-year commitment at 40% discount  1-year commitment at 20% discount or 3-year commitment at 40% discount  No access to capacity commitments  Compliance controls  No access to compliance controls through Assured Workloads  No access to compliance controls through Assured Workloads  Compliance controls through Assured Workloads  Compliance controls through Assured Workloads  VPC Service Controls  No VPC Service Controls Support  VPC Service Controls Support  VPC Service Controls Support  VPC Service Controls Support  Fine-grained security controls  No access to fine-grained security controls  Column-level access control  Column-level access control  Column-level access control  Row-level security  Row-level security  Row-level security  Dynamic data masking  Dynamic data masking  Dynamic data masking  Custom data masking  Custom data masking  Custom data masking  Business Intelligence acceleration  No access to query acceleration through BI Engine  Query acceleration through BI Engine  Query acceleration through BI Engine  Query acceleration through BI Engine  Materialized views  Query existing materialized views directly  Create materialized...
26 August 2024

บทความ

การทำ Partition และ Cluster บน BigQuery
การพัฒนาเทคโนโลยีทางด้านข้อมูลเป็นที่กล่าวถึงอย่างมากในปัจจุบัน เนื่องจากข้อมูลเหล่านั้นสามารถนำไปสำรวจ วิเคราะห์ และคาดการณ์สิ่งต่าง ๆ ในอนาคตได้ทั้งนี้การนำข้อมูลไปใช้การวิเคราะห์ให้มีประสิทธิภาพ และมีความถูกต้องแม่นยำ จำเป็นต้องใช้ข้อมูลเป็นจำนวนมากสำหรับการประมวลผล ส่งผลให้การจัดเก็บรวบรวมข้อมูลเข้ามามีบทบาทมากขึ้น แพลตฟอร์ม BigQuery เป็นสถาปัตยกรรมแบบคลังข้อมูล สามารถบริหารจัดการ และรองรับการวิเคราะห์ข้อมูลจำนวนมาก อย่างไรก็ตาม แม้ว่า BigQuery จะเป็นเทคโนโลยีที่สนับสนุนการจัดการข้อมูลขนาดใหญ่ แต่หากข้อมูลมีขนาดใหญ่จนเกินไป ก็ยังคงส่งผลทำให้ประสิทธิภาพในการวิเคราะห์ข้อมูลลดลง และมีต้นทุนที่เพิ่มมากขึ้น เพื่อลดปัญหาดังกล่าว เราสามารถแบ่งตารางที่มีขนาดใหญ่ให้เป็นส่วนต่าง ๆ ตามการ Partition เรียกว่าการทำ Partition หรือการจัดกลุ่มของข้อมูลตามค่าใน Field ที่เรียกว่าการทำ Cluster โดยบทความนี้จะเสนอวิธีการทำ Partition และ Cluster ของตารางบน BigQuery ด้วยกัน 3 วิธี คือ สำหรับการสร้างตารางแต่ละครั้ง เราสามารถสร้างตารางเป็นทั้งแบบ Partition และ Cluster หรือเลือกทำอย่างใดอย่างหนึ่ง สำหรับการเลือก Field ที่ใช้ในการทำ Partition ควรเลือกให้เหมาะสม และสอดคล้องกับข้อมูลที่ใช้ โดยทั่วไป Field ที่ถูกเลือกมาทำ Partition จะอยู่ในรูปแบบของวันที่ เวลา หรือจำนวนเต็ม โดยสำหรับบทความนี้จะเป็นการแนะนำวิธีการทำ Partition ด้วย Field ที่อยู่ในรูปแบบของวัน หรือเวลาเท่านั้น 1. การสร้างตารางแบบ Partition และ Cluster ผ่าน Cloud Console สำหรับการสร้างตารางผ่าน Cloud Console ของ BigQuery โดยเริ่มจากการสร้างตารางด้วยการกดปุ่ม ADD ทางเมนูด้านบนหน้าจอ จะปรากฏหน้าต่าง Add สำหรับกำหนดโครงสร้างของตาราง โดยในส่วนของ Popular sources เลือกเป็น Local file จากนั้นจะปรากฏหน้าต่าง Create table ทำการกำหนดค่าในส่วนต่าง ๆ ดังนี้ หลังจากการกำหนดในส่วนของ Partition เรียบร้อยแล้ว หากต้องการให้ตารางมีการทำ Cluster สามารถกำหนด Field ที่จะใช้ในการทำ Cluster ตรงส่วนของ Clustering order ซึ่งสามารถกำหนด Field ได้สูงสุด 4 Fields และเมื่อกำหนดรายละเอียดทุกอย่างเรียบร้อยแล้วทำการกดคำสั่ง Create table เพื่อสร้างตาราง ในกรณีที่ไม่มีการกำหนด Schema ของตารางไว้ก่อน ก็ยังสามารถทำ Partition ให้กับตารางใน BigQuery ได้ โดยข้อมูลจะถูกแบ่ง Partition ตามวัน หรือเวลาของข้อมูลที่ถูกเพิ่มเข้าตาราง โดยในส่วนของ Partitioning เลือกเป็น “Partition by ingestion time” และเลือกรูปแบบการทำ Partition ของข้อมูล 2. การสร้างและปรับตารางใน BigQuery ให้เป็น Partition หรือ Cluster ด้วย SQL เริ่มต้นการทำงานผ่าน Cloud Console ของ BigQuery เช่นเดียวกับวีธีแรก และกดปุ่ม + ที่เมนูด้านบนเพื่อเปิดหน้าต่าง SQL Query จากนั้นกำหนด SQL code สำหรับการสร้างตาราง โดยต้องกำหนด Schema และ Field ที่จะใช้ในการทำ Partition และ Cluster ของตาราง พร้อมทั้งกำหนดรูปแบบในการทำ Partition ของข้อมูล ตามตัวอย่างต่อไปนี้ หากต้องการปรับตารางที่ถูกสร้างไว้แล้วใน BigQuery จาก non-Partition ให้เป็นแบบ Partition และ Cluster สามารถแก้ไขตารางโดยใช้ SQL code โดยระบุตารางที่ต้องการจัดการ และกำหนดรายละเอียดของตารางใหม่ กำหนด Field ที่จะใช้ในการทำ Partition และ Cluster ของตาราง พร้อมกับการกำหนดรูปแบบในการทำ Partition ตามตัวอย่างต่อไปนี้ ตัวอย่างการกำหนดรูปแบบในการทำ Partition แบบอื่น ๆ หากต้องการกำหนด Partition ในรูปแบบอื่น ๆ สามารถศึกษารายละเอียดเพิ่มเติมได้ที่ Data definition language (DDL) statements in GoogleSQL หลังจากนั้นทำการลบตารางเดิมที่เป็นแบบ non-Partition โดยใช้คำสั่งดังนี้ 3. การสร้างตารางแบบ Partition และ Cluster ผ่าน Python code ทำการกำหนด Schema ทั้งหมดของข้อมูล ซึ่งสามารถกำหนดได้ 2 รูปแบบ คือ เริ่มต้นการทำงานด้วยการกำหนด Schema ของข้อมูล และจัดเก็บในรูปแบบของไฟล์ json ก่อน แล้วจึงทำการโหลดไฟล์ Schema นั้นมาใช้ มีข้อแนะนำให้กำหนด Field ของข้อมูลทั้งหมดให้อยู่ในรูปแบบตาราง และจัดเก็บเป็นไฟล์ csv หรือ excel ก่อน โดยต้องกำหนดรายละเอียด 2 ส่วน คือ (a) ชื่อ Field ของข้อมูล จัดเก็บไว้ในคอลัมน์ กำหนดชื่อคอลัมน์ว่า ‘name‘ และ (b) ประเภทของ Field จัดเก็บไว้ในคอลัมน์ กำหนดชื่อคอลัมน์ว่า ‘type‘ name type gender STRING nation_group STRING check_in_daily TIMESTAMP ตารางที่ 1 แสดงตัวอย่างการกำหนด Schema ในรูปแบบตาราง จากนั้นทำการปรับ Schema จากรูปแบบตารางให้อยู่ในรูปแบบของไฟล์ json ด้วย Python โดยใช้คำสั่งทำการอ่านไฟล์ Schema ที่อยู่ในรูปแบบของ csv หรือ excel และจะใช้คำสั่ง to_json() ในการปรับ Schema ให้เป็นไฟล์...
22 May 2024

บทความ

เชื่อมต่อ BigQuery ด้วย Python ใน 3 ขั้นตอน
การสำรองและกู้คืนข้อมูล PostgreSQL และการ sync ไฟล์ด้วย rsync แบบอัตโนมัติ
22 August 2022
PDPA Icon

We use cookies to optimize your browsing experience and improve our website’s performance. Learn more at our Privacy Policy and adjust your cookie settings at Settings

Privacy Preferences

You can choose your cookie settings by turning on/off each type of cookie as needed, except for necessary cookies.

Accept all
Manage Consent Preferences
  • Strictly Necessary Cookies
    Always Active

    This type of cookie is essential for providing services on the website of the Personal Data Protection Committee Office, allowing you to access various parts of the site. It also helps remember information you have previously provided through the website. Disabling this type of cookie will result in your inability to use key services of the Personal Data Protection Committee Office that require cookies to function.
    Cookies Details

  • Performance Cookies

    This type of cookie helps the Big Data Institute (Public Organization) understand user interactions with its website services, including which pages or areas of the site are most popular, as well as analyze other related data. The Big Data Institute (Public Organization) also uses this information to improve website performance and gain a better understanding of user behavior. Although the data collected by these cookies is non-identifiable and used solely for statistical analysis, disabling them will prevent the Big Data Institute (Public Organization) from knowing the number of website visitors and from evaluating the quality of its services.

  • Functional Cookies

    This type of cookie enables the Big Data Institute (Public Organization)’s website to remember the choices you have made and deliver enhanced features and content tailored to your usage. For example, it can remember your username or changes you have made to font sizes or other customizable settings on the page. Disabling these cookies may result in the website not functioning properly.

  • Targeting Cookies

    "This type of cookie helps the Big Data Institute (Public Organization) understand user interactions with its website services, including which pages or areas of the site are most popular, as well as analyze other related data. The Big Data Institute (Public Organization) also uses this information to improve website performance and gain a better understanding of user behavior. Although the data collected by these cookies is non-identifiable and used solely for statistical analysis, disabling them will prevent the Big Data Institute (Public Organization) from knowing the number of website visitors and from evaluating the quality of its services.

Save settings
This site is registered on wpml.org as a development site. Switch to a production site key to remove this banner.