You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add one of the following slugs below to see the effects of using D1 read replication.
106
+
107
+
\n/run - Queries the table without using read replication
108
+
109
+
\n/withsession - Queries the table using read replication (using "first-unconstrained")
110
+
111
+
\nUse the two options to compare the difference in query latency.`
112
+
);
113
+
}
114
+
};
84
115
```
85
116
117
+
## 6. Deploy Worker
118
+
119
+
Deploy your worker.
120
+
121
+
```sh
122
+
npx wrangler deploy
123
+
```
124
+
125
+
## 7. Compare query latency
126
+
127
+
Once deployed, you can compare the query latency when using read replication.
128
+
129
+
- Use the `/run` URL to send a read query without read replication.
130
+
- Use the `/withsession` URL to send a read query with read replication.
131
+
132
+
For both queries, the Worker script returns the `meta` object, which contains `served-by-primary` boolean field. This field indicates whether your request was served by the primary database instance.
133
+
134
+
The `d1Duration` variable shows the query latency.
135
+
136
+
## Summary
137
+
138
+
By completing this tutorial, you have:
139
+
140
+
1. Created a D1 database using a location hint.
141
+
2. Created a Worker script which uses D1 Sessions to use read replication.
142
+
3. Deployed the Worker to test the difference in query latency when using read replication.
0 commit comments