Docs
खोज⌘ K
  • Home
  • The Graph के बारे में
  • समर्थित नेटवर्क
  • Protocol Contracts
  • सबग्राफ
    • सबस्ट्रीम
      • टोकन API
        • AI Suite
          • Overview
          • Indexer टूलिंग
            • GraphTally Guide
            • Supported Network Requirements
            • Chain Integration Process Overview
            • नई श्रृंखला एकीकरण
            • संसाधन
              सबग्राफ > Best Practices

              3 मिनट

              Subgraph सर्वोत्तम प्रथा 2 - @derivedFrom का उपयोग करके अनुक्रमण और क्वेरी की प्रतिक्रियाशीलता में सुधार करें।

              TLDR

              Arrays in your schema can really slow down a Subgraph’s performance as they grow beyond thousands of entries. If possible, the @derivedFrom directive should be used when using arrays as it prevents large arrays from forming, simplifies handlers, and reduces the size of individual entities, improving indexing speed and query performance significantly.

              @derivedFrom निर्देशिका का उपयोग कैसे करें

              आपको बस अपने स्कीमा में अपने एरे के बाद एक @derivedFrom निर्देशिका जोड़ने की आवश्यकता है। ऐसा:

              1टिप्पणियाँ : [Comment!]! @derivedFrom(field: “post”)

              @derivedFrom creates efficient one-to-many relationships, enabling an entity to dynamically associate with multiple related entities based on a field in the related entity. This approach removes the need for both sides of the relationship to store duplicate data, making the Subgraph more efficient.

              @derivedFrom के लिए उदाहरण उपयोग मामला

              एक गतिशील रूप से बढ़ने वाले ऐरे का एक उदाहरण एक ब्लॉगिंग प्लेटफ़ॉर्म है जहाँ एक “Post” के कई “Comments” हो सकते हैं।

              आइए हम अपनी दो संस्थाओं, Post और Comment के साथ शुरू करते हैं।

              बिना ऑप्टिमाइजेशन के, आप इसे एक ऐरे के साथ इस प्रकार लागू कर सकते हैं:

              1type Post @entity {2  id: Bytes!3  title: String!4  content: String!5  comments: [Comment!]!6}78type Comment @entity {9  id: Bytes!10  content: String!11}

              इस तरह के ऐरे प्रभावी रूप से संबंध के पोस्ट पक्ष पर अतिरिक्त Comments डेटा को संग्रहीत करेंगे।

              यहाँ एक अनुकूलित संस्करण है जो @derivedFrom का उपयोग करता है:

              1type Post @entity {2  id: Bytes!3  title: String!4  content: String!5  comments: [Comment!]! @derivedFrom(field: "post")6}78type Comment @entity {9  id: Bytes!10  content: String!11  post: Post!12}

              बस @derivedFrom निर्देश जोड़ने से, यह स्कीमा केवल संबंध के “Comments” पक्ष पर “Comments” को संग्रहीत करेगा और संबंध के “Post” पक्ष पर नहीं। ऐरे व्यक्तिगत पंक्तियों में संग्रहीत होते हैं, जिससे उन्हें काफी विस्तार करने की अनुमति मिलती है। यदि उनका विकास अनियंत्रित है, तो इससे विशेष रूप से बड़े आकार हो सकते हैं।

              This will not only make our Subgraph more efficient, but it will also unlock three features:

              1. हम Post को क्वेरी कर सकते हैं और इसके सभी कमेंट्स देख सकते हैं।

              2. हम एक रिवर्स लुकअप कर सकते हैं और किसी भी Comment को क्वेरी कर सकते हैं और देख सकते हैं कि यह किस पोस्ट से आया है।

              3. We can use Derived Field Loaders to unlock the ability to directly access and manipulate data from virtual relationships in our Subgraph mappings.

              निष्कर्ष

              Use the @derivedFrom directive in Subgraphs to effectively manage dynamically growing arrays, enhancing indexing efficiency and data retrieval.

              For a more detailed explanation of strategies to avoid large arrays, check out Kevin Jones’ blog: Best Practices in Subgraph Development: Avoiding Large Arrays.

              सबग्राफ सर्वोत्तम प्रथाएँ 1-6

              1. सबग्राफ की गति में सुधार करें सबग्राफ प्रूनिंग के साथ

              2. indexing और क्वेरी प्रतिसादशीलता में सुधार करें @derivedFrom का उपयोग करके

              3. अपरिवर्तनीय entities और Bytes को ID के रूप में उपयोग करके Indexing और क्वेरी प्रदर्शन में सुधार करें

              4. indexing गति में सुधार करें eth_calls से बचकर

              5. समय श्रृंखला और समुच्चयन के साथ सरल और अनुकूलित करें

              6. त्वरित हॉटफ़िक्स परिनियोजन के लिए ग्राफ्टिंग का उपयोग करें

              ⁠GitHub पर संपादित करें⁠

              Pruning with indexerHintsImmutable Entities and Bytes as IDs
              इस पृष्ठ पर
              • TLDR
              • @derivedFrom निर्देशिका का उपयोग कैसे करें
              • @derivedFrom के लिए उदाहरण उपयोग मामला
              • निष्कर्ष
              • सबग्राफ सर्वोत्तम प्रथाएँ 1-6
              The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service