กลุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บางครั้งคุณอาจรับข้อมูลทั้งหมดที่ต้องการจากรายงานเดียวไม่ได้ เช่น ในกรณีที่คุณมีมิติข้อมูลและเมตริกที่ใช้ร่วมกันไม่ได้ หรือเมื่อต้องการรวมข้อมูลด้วยวิธีต่างๆ
ในกรณีเหล่านั้น คุณจะต้องเรียกใช้รายงานหลายฉบับ
นอกจากนี้ การจัดกลุ่มยังเป็นวิธีที่มีประสิทธิภาพในการปรับปรุงประสิทธิภาพของแอป ซึ่งช่วยลดจำนวนคำขอได้
ปัญหาเกี่ยวกับการส่งคำขออิสระหลายรายการ
แม้ว่าจะเป็นโซลูชันที่ใช้ง่าย แต่การส่งคำขอ API หลายรายการในเวลาสั้นๆ อาจทำให้มีโควต้าจำกัด
วิธีแก้ไขที่ดีกว่าคือให้หลีกเลี่ยงคำขอพร้อมกันทั้งหมด แล้วสร้างคำขอแบบกลุ่มแทน
รายงานแบบกลุ่ม
ในตัวอย่างของแอปพลิเคชันที่ขับเคลื่อนด้วยผู้ใช้ วิธีแรกคือการรวมคำขออิสระจำนวนมากที่สุดเท่าที่จะเป็นไปได้ลงในคำขอแบบกลุ่มเดียว
รายงาน 1: ประเทศ 10 อันดับแรกของเดือนสิงหาคม
รายงาน 2: ค่าสำหรับ 10 ประเทศเดียวกันในเดือนกรกฎาคมเพื่อเปรียบเทียบ
รายงาน 3: แชแนล 10 อันดับแรกของเดือนสิงหาคม
รายงาน 4: ค่าสำหรับช่อง 10 ช่องเดียวกันในเดือนกรกฎาคมเพื่อเปรียบเทียบ
ในตัวอย่างข้างต้น รายงาน 1 และ 3 เป็นอิสระจากกัน แต่ไม่สามารถรวมเข้าเป็นรายงานเดียว เนื่องจากมีการแจกแจงรายละเอียดข้อมูลที่แตกต่างกัน อย่างไรก็ตาม ผลิตภัณฑ์เหล่านี้สามารถอยู่รวมกันเป็นกลุ่มได้
รายงานที่ 2 และ 4 จะเรียกใช้ได้หลังจากได้รับผลลัพธ์ของชุดแรกแล้วเท่านั้น เนื่องจากเราต้องตั้งค่าตัวกรองที่เหมาะสมในคำขอ ซึ่งสามารถเรียกใช้เป็นกลุ่มที่ 2 ได้เมื่อผลลัพธ์จากกลุ่มแรกมาถึง
อีกตัวเลือกหนึ่งที่ช่วยให้รวมคำขอทั้งหมดไว้ในกลุ่มเดียวได้คือจะแสดงค่าทั้งหมดสำหรับเดือนกรกฎาคม (แทนที่จะเป็นเพียง 10 อันดับแรก) และอาจแสดงผลเป็นเดือนสิงหาคมด้วย ซึ่งอาจเป็นตัวเลือกที่เหมาะสม ทั้งนี้จะขึ้นอยู่กับขนาดของบัญชี AdSense ที่มีปัญหา และจำนวนหน่วยความจำที่มีให้กับแอปพลิเคชันของคุณ
วิธีการ
ระบบจะจัดการแบบกลุ่มแตกต่างกันไปในไลบรารีของไคลเอ็นต์แต่ละรายการ ดังนั้นคุณควรตรวจสอบเอกสารของกลุ่มเพื่อดูรายละเอียด ต่อไปนี้เป็นลิงก์ไปยังเอกสารที่เกี่ยวข้องในไลบรารีของไคลเอ็นต์หลายแห่ง
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eBatching requests improves app performance by reducing the number of API calls and mitigating quota limitations.\u003c/p\u003e\n"],["\u003cp\u003eIndependent reports, like those with incompatible dimensions or metrics, can be combined into batch requests.\u003c/p\u003e\n"],["\u003cp\u003eBatching can involve grouping related reports or retrieving broader data sets to minimize the total number of batches.\u003c/p\u003e\n"],["\u003cp\u003eSpecific batching implementations vary by client library (.NET, PHP, Python, Java, Ruby, etc.).\u003c/p\u003e\n"],["\u003cp\u003eFor handling very large reports or incompatible dimensions and metrics, refer to the provided resources for further guidance.\u003c/p\u003e\n"]]],["When single reports can't provide all necessary data due to incompatible dimensions or different aggregation needs, multiple reports are required. Batching multiple API requests improves app performance and reduces quota limitations, avoiding parallel requests. Independent requests, like retrieving top countries and channels, can be combined into a single batch. Subsequent requests for comparison data can be batched afterward, once the initial batch results are available. Client libraries offer varied methods for batching, requiring consultation of their respective documentation.\n"],null,["# Batch\n\nSometimes it's not possible to get all the information you need out of a single report, such as when you have incompatible dimensions and metrics, or when you're looking to aggregate data in different ways.\n\nIn those situations, you'll need to run multiple reports.\n\nAlso, batching is an effective way to improve your app's performance, reducing the number of requests.\n\nThe problem with making multiple independent requests\n-----------------------------------------------------\n\nWhile a simple solution to implement, making multiple API requests in a short amount of time may cause you to run into quota limitations.\n\nA better solution is to avoid the parallel requests altogether, and instead create batch requests.\n\nReport batching\n---------------\n\nIn the example of a user-driven application, a first approach would be to combine as many independent requests as possible into a single batch request.\n\n\n**Report 1:** Top 10 countries for August \n\n**Report 2:** Values for same 10 countries in July, for comparison \n\n**Report 3:** Top 10 channels for August \n\n**Report 4:** Values for same 10 channels in July, for comparison\n\nIn the above example, reports 1 and 3 are independent, but cannot be combined into a single report, since they offer different breakdowns of the data. They can, however, be batched together.\n\nReports 2 and 4 can only be run after obtaining the results of the first batch, since we need to set up an appropriate filter in the request. These can be run as a second batch, once the results from the first arrive.\n\nA different option, which would allow all requests to be combined into a single batch, would be to simply return all values for July (instead of just the top 10), and potentially August as well. This may be a reasonable option depending on the size of the AdSense account in question and the amount of memory available to your application.\n\nHow it's done\n-------------\n\nBatching is handled differently in each client library, so you should check its documentation in order to find out the details. Here are some links to the relevant documentation in several client libraries:\n\n- [.NET](https://developers.google.com/api-client-library/dotnet/guide/batch)\n- [PHP](https://developers.google.com/api-client-library/php/guide/batch)\n- [Python](https://developers.google.com/api-client-library/python/guide/batch)\n- [Java](https://code.google.com/p/google-api-java-client/wiki/Batch)\n- [Ruby](https://developers.google.com/api-client-library/ruby/guide/batch)\n\n\u003cbr /\u003e\n\nNext steps\n----------\n\n- [Running Large Reports](/adsense/management/reporting/large_reports)\n- [Incompatible Dimensions and Metrics](/adsense/management/reporting/dimensions_metrics#incompatible)"]]