دسته ای
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
گاهی اوقات دریافت تمام اطلاعات مورد نیاز از یک گزارش ممکن نیست، مانند زمانی که ابعاد و معیارهای ناسازگار دارید، یا زمانی که به دنبال جمع آوری داده ها به روش های مختلف هستید.
در این شرایط، باید چندین گزارش را اجرا کنید.
همچنین، دستهبندی روشی مؤثر برای بهبود عملکرد برنامه شما است و تعداد درخواستها را کاهش میدهد.
مشکل ایجاد چندین درخواست مستقل
در حالی که یک راه حل ساده برای پیاده سازی، ایجاد چندین درخواست API در مدت زمان کوتاه ممکن است باعث شود با محدودیت های سهمیه مواجه شوید.
راه حل بهتر این است که از درخواست های موازی به طور کلی اجتناب کنید و در عوض درخواست های دسته ای ایجاد کنید.
گزارش دسته بندی
در مثال یک برنامه کاربردی کاربر محور، اولین رویکرد ترکیب کردن هر چه بیشتر درخواستهای مستقل در یک درخواست دستهای است.
گزارش 1: 10 کشور برتر برای ماه اوت
گزارش 2: مقادیر برای همان 10 کشور در ماه جولای، برای مقایسه
گزارش 3: 10 کانال برتر ماه اوت
گزارش 4: مقادیر برای همان 10 کانال در ماه جولای، برای مقایسه
در مثال بالا، گزارشهای 1 و 3 مستقل هستند، اما نمیتوان آنها را در یک گزارش ترکیب کرد، زیرا تفکیکهای متفاوتی از دادهها را ارائه میدهند. با این حال، آنها را می توان با هم جمع کرد.
گزارش های 2 و 4 تنها پس از به دست آوردن نتایج دسته اول قابل اجرا هستند، زیرا باید یک فیلتر مناسب در درخواست تنظیم کنیم. این ها را می توان به عنوان یک دسته دوم اجرا کرد، پس از رسیدن نتایج از اول.
یک گزینه متفاوت، که به همه درخواستها اجازه میدهد تا در یک دسته واحد ترکیب شوند، این است که به سادگی تمام مقادیر را برای ماه جولای (بهجای فقط 10 مورد برتر) و احتمالاً اوت نیز برگرداند. این ممکن است بسته به اندازه حساب AdSense مورد نظر و میزان حافظه موجود در برنامه شما، گزینه معقولی باشد.
چگونه انجام می شود
دستهبندی در هر کتابخانه مشتری متفاوت است، بنابراین باید اسناد آن را بررسی کنید تا جزئیات را بیابید. در اینجا چند پیوند به اسناد مربوطه در چندین کتابخانه مشتری وجود دارد:
مراحل بعدی
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\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)"]]