Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test skip encoding #8615

Open
wants to merge 1 commit into
base: max/sql-row-interface
Choose a base branch
from
Open

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Nov 28, 2024

prototype before/after:

BenchmarkOltpIndexScan-12    	     206	   5190640 ns/op	 5243491 B/op	  140229 allocs/op
BenchmarkOltpIndexScan-12    	     650	   1785686 ns/op	 3883499 B/op	   20767 allocs/op

The premise of this is a custom row type:

type ProllyRow struct {
	key, value val.Tuple
	kd, vd     val.TupleDesc
	ords       []int // placement access
}

func (r ProllyRow) GetBytes(i int, typ sql.Type) ([]byte, error) {
	pos := r.ords[i]

	if pos < r.kd.Count() {
		ret := r.kd.GetField(pos, r.key)
		return ret, nil
	}

	pos -= r.kd.Count()
	ret := r.vd.GetField(pos, r.value)
	return ret, nil
}

The idea is to go from val.Tuple straight to wire values:

	outVals := make([]sqltypes.Value, len(sch))
	var err error
	if br, ok := row.(sql.BytesRow); ok {
		for i, col := range sch {
			buf, err := br.GetBytes(i, col.Type)
			outVals[i] = sqltypes.MakeTrusted(col.Type.Type(), buf)
			if err != nil {
				return nil, err
			}
		}
		return outVals, nil
	}
  • correctness considerations for when storage encoding is not consistent with MySQL byte encoding
  • certain values will have to be materialized to satisfy engine logic that operates on Go types
  • the ordinal mapping above is 1-step, while main has 2-steps
  • this doesn't work with virtual columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant