• I assuming here that you're talking about the 'page buffer cache'. This cache contains recently read pages,which are periodically cycled out using an algorithm based on frequency of usage. The cache pages aren't tied the query or process that read them, but each page can be identified by object type and object name.

    The following query will provide detailed information about page buffer cache allocation.


    -- Object level allocation for each database:
    IF OBJECT_ID('tempdb..#BufferCacheAllocation') IS NOT NULL
        DROP TABLE #BufferCacheAllocation;
    GO
    CREATE TABLE #BufferCacheAllocation
    (
        Database_Name VARCHAR(200) NOT NULL,
        Object_Name VARCHAR(200) NULL,
        Page_Type VARCHAR(30) NULL,
        Index_Name VARCHAR(200) NULL,
        Index_Type VARCHAR(30) NULL,
        Data_Compression_Desc VARCHAR(20) NULL,
        Row_Count BIGINT NULL,
        BufferAllocated_MB BIGINT NULL,
        BufferWaste_MB BIGINT NULL
    );
    exec sp_MsForEachDB
    '
    USE ?;
    INSERT INTO #BufferCacheAllocation
    (
        Database_Name,
        Object_Name,
        Page_Type,
        Index_Name,
        Index_Type,
        Data_Compression_Desc,
        Row_Count,
        BufferAllocated_MB,
        BufferWaste_MB
    )
    SELECT
        db_name(database_id) Database_Name,
        obj.[name] Object_Name,
        bd.page_type as Page_Type,
        i.[name] Index_Name,
        i.[type_desc] Index_Type,
        obj.Data_Compression_Desc,
        sum(row_count) as Row_Count,
        (count_big(*) * 8192) / (1024 * 1024) as BufferAllocated_MB,
        sum(free_space_in_bytes) / (1024 * 1024) as BufferWaste_MB
    FROM sys.dm_os_buffer_descriptors AS bd
      LEFT JOIN
      (
       SELECT object_name(object_id) AS name
        ,index_id ,allocation_unit_id
                , object_id
                , data_compression_desc
       FROM sys.allocation_units AS au
        INNER JOIN sys.partitions AS p
          ON au.container_id = p.hobt_id
           AND (au.type = 1 OR au.type = 3)
       UNION ALL
       SELECT object_name(object_id) AS name
        ,index_id ,allocation_unit_id
                , object_id
                , data_compression_desc
       FROM sys.allocation_units AS au
        INNER JOIN sys.partitions AS p
          ON au.container_id = p.hobt_id
           AND au.type = 2
      ) AS obj
       ON bd.allocation_unit_id = obj.allocation_unit_id
    LEFT JOIN sys.indexes i on i.object_id = obj.object_id AND i.index_id = obj.index_id
    WHERE database_id = db_id()
    GROUP BY database_id, obj.name, obj.index_id , i.[name], i.[type_desc], obj.Data_Compression_Desc, bd.page_type;
    ';

    SELECT SUM(BufferAllocated_MB) AS BufferAllocated_MB, SUM(BufferWaste_MB) AS BufferWaste_MB
        FROM #BufferCacheAllocation;

    SELECT Database_Name, SUM(BufferAllocated_MB) AS BufferAllocated_MB, SUM(BufferWaste_MB) AS BufferWaste_MB
        FROM #BufferCacheAllocation
            GROUP BY Database_Name
                ORDER BY SUM(BufferAllocated_MB) DESC;

    SELECT Page_Type, Index_Type, Data_Compression_Desc
        , SUM(BufferAllocated_MB) AS Allocated_MB, SUM(BufferWaste_MB) AS BufferWaste_MB
        FROM #BufferCacheAllocation
            GROUP BY Page_Type, Index_Type, Data_Compression_Desc
                ORDER BY SUM(BufferAllocated_MB) DESC;

    SELECT * FROM #BufferCacheAllocation ORDER BY BufferAllocated_MB DESC;

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho