Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

Commit 84aae81

Browse files
committed
optimize SqlpadTauChart.componentDidUpdate
Turns out deep-equal on a collection of 5000+ rows is pretty slow. TauCharts still struggles with large amounts of data, but there’s no way around that since it is svg based. Maybe limit dataset user is allowed to visualize?
1 parent b02bdc2 commit 84aae81

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

client-js/SqlpadTauChart.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ var _ = require('_')
33
var chartDefinitions = require('./ChartDefinitions.js')
44
var SpinKitCube = require('./SpinKitCube.js')
55
var tauCharts = require('tauCharts')
6-
var deepEqual = require('deep-equal')
76
var Alert = require('react-s-alert').default
87

98
var SqlpadTauChart = React.createClass({
109
componentDidUpdate: function (prevProps) {
11-
if (!deepEqual(prevProps.queryResult, this.props.queryResult)) {
10+
var prevResultId = (prevProps.queryResult ? prevProps.queryResult.id : null)
11+
var currentResultId = (this.props.queryResult ? this.props.queryResult.id : null)
12+
if (prevResultId !== currentResultId) {
1213
console.log('rendering because queryResults changed')
1314
this.renderChart()
1415
}

models/QueryResult.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
should expect the data to be in this format
77
*/
88
var _ = require('lodash')
9+
var uuid = require('uuid')
910

1011
function isNumberLike (n) {
1112
return (!isNaN(parseFloat(n)) && isFinite(n))
1213
}
1314

1415
function QueryResult () {
16+
this.id = uuid.v1() // each result has unique id. used to determine whether results changed in React
1517
this.startTime
1618
this.stopTime
1719
this.queryRunTime

0 commit comments

Comments
 (0)