Leistung steigern
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Dokument werden Verfahren beschrieben, mit denen Sie die Leistung Ihrer Anwendung verbessern können.
Die Dokumentation für die von Ihnen verwendete API sollte Folgendes enthalten:
ähnliche Seite mit weiteren Details zu einigen dieser Themen.
Sehen Sie sich zum Beispiel die
Seite mit Tipps zur Leistungsoptimierung für die Google Drive API
Informationen zu gzip
Diese Clientbibliothek fordert für alle API-Antworten und Entpacken eine gzip-Komprimierung an
die Daten für Sie.
Dies erfordert zwar zusätzliche CPU-Zeit zum Dekomprimieren der Ergebnisse,
die Abwägung der Netzwerkkosten
sich in der Regel lohnen.
Teilantwort (fields-Parameter)
Standardmäßig wird vom Server nach der Verarbeitung einer Anfrage die komplette Darstellung einer Ressource zurückgeliefert.
Für eine bessere Leistung
können Sie den Server auffordern, nur die Felder zu senden, die Sie wirklich benötigen, und erhalten dann eine Teilantwort.
Um eine Teilantwort anzufordern,
Fügen Sie jeder API-Methode den Standardparameter Fields
hinzu.
Der Wert dieses Parameters gibt die Felder an, die zurückgegeben werden sollen.
Sie können diesen Parameter mit jeder beliebigen Anfrage verwenden, die Antwortdaten zurückgibt.
Im folgenden Code-Snippet
Die Methode GetRest
des Discovery-Dienstes wird aufgerufen.
Der Wert des Parameters Fields
ist auf description,title
festgelegt.
Daher enthält das zurückgegebene Objekt nur die Felder „description“ und „title“.
var service = new DiscoveryService();
var request = service.Apis.GetRest("calendar", "v3");
request.Fields = "description,title";
var result = request.Execute();
Wie Sie sehen, werden die gewünschten Felder durch Kommas getrennt.
und Schrägstriche werden verwendet, um Felder in übergeordneten Feldern anzuzeigen.
Es gibt andere Formatierungsoptionen für den Parameter Fields
.
Weitere Informationen finden Sie in den Tipps zur Leistungssteigerung. Seite
in der Dokumentation der von Ihnen verwendeten API.
Teilaktualisierung (Patch)
Wenn die aufgerufene API Patch unterstützt,
können Sie beim Ändern von Ressourcen
das Senden unnötiger Daten vermeiden.
Für diese APIs können Sie die Methode Patch
aufrufen und
Geben Sie die Argumente an, die Sie für die Ressource ändern möchten.
Weitere Informationen zur Patch-Semantik
finden Sie unter „Tipps zur Leistungssteigerung“ in der Dokumentation der von Ihnen verwendeten API.
Batch
Wenn Sie viele kleine Anfragen senden, profitieren Sie möglicherweise von
Batching,
Dadurch können diese Anfragen
in einer einzigen HTTP-Anfrage gebündelt werden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-26 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003eThis document provides techniques to enhance your application's performance by reducing network costs and unnecessary data transfers.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003eFields\u003c/code\u003e parameter for partial responses, retrieving only the necessary data from the server.\u003c/p\u003e\n"],["\u003cp\u003eEmploy \u003ccode\u003ePatch\u003c/code\u003e for partial updates, sending only modified data when making changes to resources.\u003c/p\u003e\n"],["\u003cp\u003eLeverage batching to combine multiple small requests into a single HTTP request, reducing overhead.\u003c/p\u003e\n"],["\u003cp\u003eConsult the specific API documentation's "Performance Tips" page for detailed guidance on these techniques.\u003c/p\u003e\n"]]],[],null,["# Improve Performance\n\nThis document covers techniques you can use to improve the performance of your application.\nThe documentation for the specific API you are using should have a\nsimilar page with more detail on some of these topics.\nFor example, see the\n[Performance Tips page for the Google Drive API](/drive/performance).\n\nAbout gzip\n----------\n\n\nThis client library requests gzip compression for all API responses and unzips\nthe data for you.\nAlthough this requires additional CPU time to uncompress the results,\nthe tradeoff with network costs usually makes it worthwhile.\n\nPartial response (fields parameter)\n-----------------------------------\n\n\nBy default, the server sends back the full representation of a resource after processing requests.\nFor better performance,\nyou can ask the server to send only the fields you really need and get a *partial response* instead.\n\n\nTo request a partial response,\nadd the standard `Fields` parameter to any API method.\nThe value of this parameter specifies the fields you want returned.\nYou can use this parameter with any request that returns response data.\n\n\nIn the following code snippet,\nthe `GetRest` method of the Discovery service is called.\nThe value of the `Fields` parameter is set to `description,title`.\nAs a result, the returned object will include only the description and title fields. \n\n```gdscript\nvar service = new DiscoveryService();\nvar request = service.Apis.GetRest(\"calendar\", \"v3\");\nrequest.Fields = \"description,title\";\nvar result = request.Execute();\n \n```\n\n\nNote how commas are used to delimit the desired fields,\nand slashes are used to indicate fields that are contained in parent fields.\nThere are other formatting options for the `Fields` parameter;\nfor details, see the \"Performance Tips\" page\nin the documentation for the API you are using.\n\nPartial update (patch)\n----------------------\n\n\nIf the API you are calling supports patch,\nyou can avoid sending unnecessary data when modifying resources.\nFor these APIs, you can call the `Patch` method and\nsupply the arguments you wish to modify for the resource.\n\n\nFor more information about patch semantics,\nsee the \"Performance Tips\" page in the documentation for the API you are using.\n\nBatch\n-----\n\n\nIf you are sending many small requests you may benefit from\n[batching](/api-client-library/dotnet/guide/batch),\nwhich allows those requests to be bundled into a single HTTP request."]]