---
original_url: "https://jace.pro/blog/what-is-a-shard-and-how-can-i-find-the-one-this-table-is-on/"
format: markdown
ai_optimized: true
---

What is a shard and how can I find the one this table is on?# What is a shard and how can I find the one this table is on?

June 6, 2022 [gliderecord ](/tags/gliderecord/)[servicenow](/tags/servicenow/)

  Enable AI AnimationI have this code snippet;

`// The following script (or variant thereof) can be used in 
// /sys.scripts.do or in a server-side script to determine
// the current shard for a table. 

printCurrentShard('sysevent'); 

function printCurrentShard(pTableName) { 
  var gr = new GlideRecord('sys_table_rotation'); 
  if (pTableName) { 
    gr.addQuery('name', '=', pTableName); 
  } 
  gr.query(); 
  while (gr.next()) { 
    try { 
      var tre =
Packages.com.snc.db.replicate.TableRotationExtensions.get();

      var extension = tre.getExtension(gr.name); 
      var tablename = extension.getTableName(); 
    } catch (e) { 
      gs.print('Error getting current shard for table ' + gr.name); 
    } finally { 
      gs.print('The current shard of table ' + gr.name + ' is ' + tablename); 
    } 
  } 
} `
---
[View this page on GitHub](https://github.com/jacebenson/jace.pro/tree/main/./src/posts/2022/2022-06-06-what-is-a-shard-and-how-can-i-find-the-one-this-table-is-on.md).

[What is a shard and how can I find the one this table is on?](https://jace.pro/blog/what-is-a-shard-and-how-can-i-find-the-one-this-table-is-on/) [Jace Benson](https://jace.pro) ![Jace Benson](https://jace.pro/icon-512x512.png)

---

*This content is from Jace Benson's ServiceNow and tech blog at jace.pro*
*Original post: https://jace.pro/blog/what-is-a-shard-and-how-can-i-find-the-one-this-table-is-on/*
